package com.realtyManage.springboot.Service.impl;

import aj.org.objectweb.asm.Handle;
import com.alibaba.fastjson.JSONArray;
import com.aliyun.oss.model.ObjectListing;
import com.realtyManage.springboot.Config.MyLog;
import com.realtyManage.springboot.Dao.*;
import com.realtyManage.springboot.Model.Do.CustomerRegistration;
import com.realtyManage.springboot.Model.Do.HouseDetail;
import com.realtyManage.springboot.Model.Do.User;
import com.realtyManage.springboot.Model.Vo.BaseEntity;
import com.realtyManage.springboot.Model.Vo.CustomReEntity;
import com.realtyManage.springboot.Service.ICustomerRegistrationService;
import com.realtyManage.springboot.Service.ISpecialOfferHouseService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.*;
import javax.transaction.Transactional;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * CustomerRegistrationService
 * @Author 杭州素色网络科技有限公司
 * @Date 2019/9/6
 **/
@Service
@Transactional
public class CustomerRegistrationServiceImpl implements ICustomerRegistrationService {
    @Autowired
    private CustomerRegistrationRepository customerRegistrationRepository;

    @Autowired
    private DictionariesRepository dictionariesRepository;

    @Autowired
    private HouseDetailRepository houseDetailRepository;

    @Autowired
    private CustomerRecordRepository customerRecordRepository;

    @Autowired
    private UserServiceImpl userServiceImpl;

    @Autowired
    private DictionariesZeroRepository dictionariesZeroRepository;

    @Override
    public List<CustomerRegistration> findAll() {
        return customerRegistrationRepository.findAll();
    }


   // @MyLog(value = "查看客户列表")
    @Override
    public Page<CustomerRegistration> findPagedByWhereClause(CustomReEntity customReEntity) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Integer pageNumber = customReEntity.getPageNumber()-1;
        Integer pageSize = customReEntity.getPageSize();
        Integer s = null;
        Integer e = null;
        //系统时间
        String thisTime = (sdf.format(new Date())).toString();
        // 排序条件 默认最新
        Sort sort = new Sort(Sort.Direction.DESC, "id");
        if(customReEntity.getSort() != null){
            if (customReEntity.getSort().equals("DESC")) {
                sort = new Sort(Sort.Direction.DESC, customReEntity.getSortField());
            } else if(customReEntity.getSort().equals("ASC")){
                sort = new Sort(Sort.Direction.ASC, customReEntity.getSortField());
            }
        }
        Pageable pageable = PageRequest.of(pageNumber,pageSize,sort);
        if (customReEntity.getTmp() != null) {
            String[] values = customReEntity.getTmp().split(",");
            for (String id : values) {
                String name = dictionariesZeroRepository.findType(id);
                String kay = name.substring(0,name.indexOf(","));
                String val = name.substring(name.indexOf(",")+1,name.length());
                if (kay.equals("zycs")){
                    customReEntity.setHomeOwnership(val);
                }else if(kay.equals("khly")){
                    customReEntity.setCustomerSource(val);
                }else if (kay.equals("khnjd")){
                    if (val.indexOf("以上") > 0){
                        val = val.substring(0,2);
                        customReEntity.setAge(Integer.valueOf(val));
                        customReEntity.setGtOrLt("gt");
                    }else if(val.indexOf("以下") > 0){
                        val = val.substring(0,2);
                        customReEntity.setAge(Integer.valueOf(val));
                        customReEntity.setGtOrLt("lt");
                    }else if (val.indexOf("至") > 0){
                        s = Integer.valueOf(val.substring(0,2));
                        e = Integer.valueOf(val.substring(val.indexOf("至")+1,val.length()));
                    }
                }else if(kay.equals("yxwylx")){
                    //意向物业类型
                    customReEntity.setIntentionPropertyType(val);
                }else if(kay.equals("qy")){
                    //区域
                    customReEntity.setAreaName(val);
                }else if(kay.equals("dfcs")){
                    //到访次数
                    customReEntity.setComeNum(val);
                }else if (kay.equals("hztj")){
                    customReEntity.setAccessKnowledge(val);
                }else if (kay.equals("mjxq")){
                    customReEntity.setAreaNeed(val);
                }else if (kay.equals("zjxq")){
                    customReEntity.setTotalNeed(val);
                }else if(kay.equals("fkfs")){
                    customReEntity.setPaymentType(val);
                }else if(kay.equals("hxxq")){
                    customReEntity.setHouseTypeNeed(val);
                }else if(kay.equals("klys")){
                    customReEntity.setConsiderType(val);
                }else if(kay.equals("jgjsd")){
                    customReEntity.setPriceAcceptance(val);
                }else if(kay.equals("yxhx")){
                    customReEntity.setIntentionalHouseholdType(val);
                }else if(kay.equals("jjyy")){
                    customReEntity.setRefuseReason(val);
                }else if(kay.equals("khzy")){
                    customReEntity.setCustomerOccupation(val);
                }else if(kay.equals("jtjg")){
                    customReEntity.setFamilyStructure(val);
                }else if(kay.equals("khzt")){
                    customReEntity.setCustomerType(val);
                }else if(kay.equals("tfyy")){
                    customReEntity.setCheckOutReason(val);
                }else if(kay.equals("sfkgybf")){
                    customReEntity.setModelHouses(val);
                }
            }
        }
        //动态查询条件
        Integer finalS = s;
        Integer finalE = e;
        Specification<CustomerRegistration> specification = (Specification<CustomerRegistration>)(root, query, criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (customReEntity.getName() != null && customReEntity.getName() != "") {
                Predicate p0 = criteriaBuilder.like(root.get("name"), "%" + customReEntity.getName() + "%");
                list.add(p0);
            }
            if(customReEntity.getPhone() != null){
                Predicate p1 = criteriaBuilder.like(root.get("phone"),"%"+customReEntity.getPhone()+"%");
                list.add(p1);
            }
            Predicate p2 = criteriaBuilder.notEqual(root.get("isSystem"),1);
            list.add(p2);
            if(customReEntity.getHomeOwnership() != null){
                //职业次数
                Predicate p3 = criteriaBuilder.equal(root.get("homeOwnership"),customReEntity.getHomeOwnership());
                list.add(p3);
            }
            if(customReEntity.getCustomerSource() != null){
                //客户来源
                Predicate p4 = criteriaBuilder.equal(root.get("customerSource"),customReEntity.getCustomerSource());
                list.add(p4);
            }
            if(customReEntity.getAge() != null){
                //客户年纪不分段
                Predicate p5 = null;
                if (customReEntity.getGtOrLt().equals("lt")){
                     p5 = criteriaBuilder.lt(root.get("age"),customReEntity.getAge());
                }else{
                     p5 = criteriaBuilder.gt(root.get("age"),customReEntity.getAge());
                }
                list.add(p5);
            }else if(finalS != null && finalE != null){
                //客户年纪分段
                Predicate p5 = criteriaBuilder.between(root.get("age"), finalS, finalE);
                list.add(p5);
            }
            if(customReEntity.getIntentionPropertyType() != null){
                //意向物业类型
                Predicate p6 = criteriaBuilder.equal(root.get("intentionPropertyType"),customReEntity.getIntentionPropertyType());
                list.add(p6);
            }
            if (customReEntity.getAreaName() != null){
                //区域
                Predicate p7 = criteriaBuilder.equal(root.get("areaName"),customReEntity.getAreaName());
                list.add(p7);
            }
            if(customReEntity.getComeNum() != null){
                //到访次数
                Predicate p8 = criteriaBuilder.equal(root.get("comeNum"),customReEntity.getComeNum());
                list.add(p8);
            }
            if(customReEntity.getAccessKnowledge() != null){
                //获知
                Predicate p9 = criteriaBuilder.equal(root.get("accessKnowledge"),customReEntity.getAccessKnowledge());
                list.add(p9);
            }
            if(customReEntity.getAreaNeed() != null){
                //面积需求
                Predicate p10 = criteriaBuilder.equal(root.get("areaNeed"),customReEntity.getAreaNeed());
                list.add(p10);
            }
            if(customReEntity.getTotalNeed() != null){
                //总价需求
                Predicate p11 = criteriaBuilder.equal(root.get("totalNeed"),customReEntity.getTotalNeed());
                list.add(p11);
            }
            if(customReEntity.getPaymentType() != null){
                //付款方式
                Predicate p12 = criteriaBuilder.equal(root.get("paymentType"),customReEntity.getPaymentType());
                list.add(p12);
            }
            if(customReEntity.getHouseTypeNeed() != null){
                //户型需求
                Predicate p13 = criteriaBuilder.equal(root.get("HouseTypeNeed"),customReEntity.getHouseTypeNeed());
                list.add(p13);
            }
            if(customReEntity.getConsiderType() != null){
                //考虑因素
                Predicate p14 = criteriaBuilder.equal(root.get("considerType"),customReEntity.getConsiderType());
                list.add(p14);
            }
            if(customReEntity.getPriceAcceptance() != null){
                //价格接受度
                Predicate p15 = criteriaBuilder.equal(root.get("priceAcceptance"),customReEntity.getPriceAcceptance());
                list.add(p15);
            }
            if(customReEntity.getIntentionalHouseholdType() != null){
                //意向户型
                Predicate p16 = criteriaBuilder.equal(root.get("intentionalHouseholdType"),customReEntity.getIntentionalHouseholdType());
                list.add(p16);
            }
            if(customReEntity.getRefuseReason() != null){
                //拒绝原因
                Predicate p17 = criteriaBuilder.equal(root.get("refuseReason"),customReEntity.getRefuseReason());
                list.add(p17);
            }
            if(customReEntity.getCustomerOccupation() != null){
                //客户职业
                Predicate p18 = criteriaBuilder.equal(root.get("customerOccupation"),customReEntity.getCustomerOccupation());
                list.add(p18);
            }
            if(customReEntity.getFamilyStructure() != null){
                //家庭结构
                Predicate p19 = criteriaBuilder.equal(root.get("familyStructure"),customReEntity.getFamilyStructure());
                list.add(p19);
            }
            if(customReEntity.getCustomerType() != null){
                //客户状态
                Predicate p20 = criteriaBuilder.equal(root.get("customerType"),customReEntity.getCustomerType());
                list.add(p20);
            }
            if(customReEntity.getCustomerIntention() != null){
                //客户意向
                Predicate p21 = criteriaBuilder.equal(root.get("customerIntention"),customReEntity.getCustomerIntention());
                list.add(p21);
            }
            if(customReEntity.getCheckOutReason() != null){
                //退房原因
                Predicate p22 = criteriaBuilder.equal(root.get("checkOutReason"),customReEntity.getCheckOutReason());
                list.add(p22);
            }
            if(customReEntity.getModelHouses() != null){
                //样板房
                Predicate p23 = criteriaBuilder.equal(root.get("modelHouses"),customReEntity.getModelHouses());
                list.add(p23);
            }
            if(customReEntity.getReceptionId() != null){
                //置业顾问id
                Predicate p24 = criteriaBuilder.equal(root.get("receptionId"),customReEntity.getReceptionId());
                list.add(p24);
            }
            return criteriaBuilder.and(list.toArray(new Predicate[0]));
        };
        Page<CustomerRegistration> lst = customerRegistrationRepository.findAll(specification, pageable);
        Map<String, String> map = new HashMap<String,String>();
        if (customReEntity.getTmp() != null) {
            String[] values = customReEntity.getTmp().split(",");
            for (String id : values) {
                String name = dictionariesZeroRepository.findType(id);
                String kay = name.substring(0,name.indexOf(","));
                String val = name.substring(name.indexOf(",")+1,name.length());
                if (kay.equals("zycs")){
                    map.put("homeOwnership","置业次数");
                }else if(kay.equals("khly")){
                    map.put("customerSource","客户来源");
                }else if (kay.equals("khnjd")){
                    map.put("age","客户年纪段");
                }else if(kay.equals("yxwylx")){
                    map.put("intentionPropertyType","意向物业类型");
                }else if(kay.equals("qy")){
                    map.put("areaName","区域");
                }else if (kay.equals("dfcs")){
                    map.put("comeNum","到访次数");
                }else if (kay.equals("hztj")){
                    map.put("accessKnowledge","获知途径");
                }else if (kay.equals("mjxq")){
                    map.put("areaNeed","面积需求");
                }else if (kay.equals("zjxq")){
                    map.put("totalNeed","总价需求");
                }else if (kay.equals("fkfs")){
                    map.put("paymentType","付款方式");
                }else if (kay.equals("hxxq")){
                    map.put("HouseTypeNeed","户型需求");
                }else if (kay.equals("klys")){
                    map.put("considerType","考虑因素");
                }else if (kay.equals("jgjsd")){
                    map.put("priceAcceptance","价格接受度");
                }else if (kay.equals("yxhx")){
                    map.put("intentionalHouseholdType","意向户型");
                }else if (kay.equals("jjyy")){
                    map.put("refuseReason","拒绝原因");
                }else if(kay.equals("khzy")){
                    map.put("customerOccupation","客户职业");
                }else if(kay.equals("jtjg")){
                    map.put("familyStructure","家庭结构");
                }else if(kay.equals("khzt")){
                    map.put("customerType","客户状态");
                }else if(kay.equals("tfyy")){
                    map.put("checkOutReason","退房原因");
                }else if(kay.equals("sfkgybf")){
                    map.put("modelHouses","是否看过样板房");
                }
            }
        }
        //查询来访记录信息
        for(CustomerRegistration customerRegistration : lst.getContent()){
            customerRegistration.setRecord(customerRegistrationRepository.queryCustomerRecordList(customerRegistration.getId()));
            customerRegistration.setTitle(map);
            customerRegistration.setLfNum(customerRegistration.getRecord().size());
            customerRegistration.setComeNum(String.valueOf(customerRegistration.getRecord().size()));
        }
        return lst;
    }


    @Override
    public int saveCustomerRegistrationInfo(CustomerRegistration customerRegistration) {
        customerRegistration.setIsShow(0);
        customerRegistration.setEffective(1);
        customerRegistration.setIsSystem(0);
        return customerRegistrationRepository.saveAndFlush(customerRegistration).getId();
    }

    /*@Override
    public boolean updateHouseInfo(HouseDetail houseDetail) {
        if(customerRegistrationRepository.update(houseDetail)==1){
            return true;
        }else{
            return false;
        }
    }*/

    @Override
    public List<String> findByNameLike(String houseName) {
        return customerRegistrationRepository.findByNameLike(houseName);
    }

    @MyLog(value = "查询客户统计")
    @Override
    public CustomReEntity queryCountCustom(String yar) {
        CustomReEntity ce = new CustomReEntity();
        Integer yxNum = 0;  //有效客户
        Integer rcNum = 0;  //认筹客户
        Integer xdNum = 0;  //小定客户
        Integer A = 0;  //A类型客户
        Integer B = 0;  //B类型客户
        Integer C = 0;  //C类型客户
        Integer D = 0;  //D类型客户
        if (yar != null && yar != ""){
            List<CustomerRegistration> lst = customerRegistrationRepository.queryCountCustom(yar);
            if(lst.size() > 0){
                for (CustomerRegistration customerRegistration : lst){
                    if (customerRegistration.getEffective() == 1){
                        yxNum ++;
                    }
                    if (customerRegistration.getIdentify() == 1){
                        rcNum ++;
                    }
                    if (customerRegistration.getLargeSum() == 1){
                        xdNum ++;
                    }
                    if (customerRegistration.getLevel().equals("A")){
                        A ++;
                    }else if (customerRegistration.getLevel().equals("B")){
                        B ++;
                    }else if (customerRegistration.getLevel().equals("C")){
                        C ++;
                    }else {
                        D ++;
                    }
                }
                ce.setZlfNum(lst.size());
                ce.setYxNum(yxNum);
                ce.setRcNum(rcNum);
                ce.setXdNum(xdNum);
                ce.setA(A);
                ce.setB(B);
                ce.setC(C);
                ce.setD(D);
                return ce;
            }
        }else{
            List<CustomerRegistration> lst = customerRegistrationRepository.queryCountCustomS();
            if(lst.size() > 0){
                for (CustomerRegistration customerRegistration : lst){
                    if (customerRegistration.getEffective() == 1){
                        yxNum ++;
                    }
                    if (customerRegistration.getIdentify() == 1){
                        rcNum ++;
                    }
                    if (customerRegistration.getLargeSum() == 1){
                        xdNum ++;
                    }
                    if (customerRegistration.getLevel() != null){
                        if (customerRegistration.getLevel().equals("A")){
                            A ++;
                        }else if (customerRegistration.getLevel().equals("B")){
                            B ++;
                        }else if (customerRegistration.getLevel().equals("C")){
                            C ++;
                        }else {
                            D ++;
                        }
                    }
                }
                ce.setZlfNum(lst.size());
                ce.setYxNum(yxNum);
                ce.setRcNum(rcNum);
                ce.setXdNum(xdNum);
                ce.setA(A);
                ce.setB(B);
                ce.setC(C);
                ce.setD(D);
                return ce;
            }
        }
        return null;
    }

    @Override
    public CustomerRegistration findByPhone(String phone){
        return customerRegistrationRepository.findByPhone(phone);
    }

    @MyLog(value = "查询特价房")
    @Override
    public List querySalesperson(){
        return customerRegistrationRepository.querySalesperson();
    }

    @Override
    public void addCustomer() {
        SimpleDateFormat sda = new SimpleDateFormat("yyyy-MM-dd");
        CustomerRegistration customerRegistration = new CustomerRegistration();
        String thisTime = sda.format(new Date());
        List<CustomerRegistration> list = customerRegistrationRepository.findByLikeTime(thisTime);
        if (list.size() < 1){
            customerRegistration.setComeTime(new Date());
            customerRegistration.setIsSystem(1);
            customerRegistrationRepository.save(customerRegistration).getId();
        }
    }

    @MyLog(value = "查询客户来访记录")
    @Override
    public List<Object> queryCountComeSalesperson(String sTime, String eTime, String uid){
        if (uid != null){
            return customerRegistrationRepository.queryCountComeSalespersonE(sTime,eTime,uid);
        }else{
            return customerRegistrationRepository.queryKv(sTime,eTime);
        }
    }

    @Override
    public  int queryCountCustomNum(String time,String uid){
        if (uid != null){
            return  customerRegistrationRepository.queryCountCustomNumE(time,uid);
        }else{
            return customerRegistrationRepository.queryCountCustomNum(time);
        }
    }

    @Override
    public List<Object> queryCountComeSalespersonMonth(String sTime, String eTime, String uid){
        if (uid != null){
            return customerRegistrationRepository.queryCountComeSalespersonMonthE(sTime,eTime,uid);
        }else{
            return customerRegistrationRepository.queryCountComeSalespersonMonth(sTime,eTime);
        }
    }

    @MyLog(value = "查询客户意向")
    @Override
    public List<String> queryCountIntention(String sTime, String eTime, String uid) {
        if (uid != null){
            return customerRegistrationRepository.queryCountIntentionE(sTime,eTime,uid);
        }else{
            return customerRegistrationRepository.queryCountIntention(sTime,eTime);
        }
    }

    @MyLog(value = "查询客户面积需求")
    @Override
    public List<String> queryCountAreaNeed(String sTime, String eTime, String uid) {
        if (uid != null){
            return customerRegistrationRepository.queryCountAreaNeedE(sTime,eTime,uid);
        }else{
            return customerRegistrationRepository.queryCountAreaNeed(sTime,eTime);
        }
    }

    @Override
    public Page<CustomerRegistration> queryMyCustomerList(CustomReEntity customReEntity,Integer id) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Integer pageNumber = customReEntity.getPageNumber()-1;
        Integer pageSize = customReEntity.getPageSize();
        Integer i = 0;
        // 排序条件 默认最新
        Sort sort = new Sort(Sort.Direction.DESC, "id");
        if(customReEntity.getSort() != null){
            if (customReEntity.getSort().equals("DESC")) {
                sort = new Sort(Sort.Direction.DESC, customReEntity.getSortField());
            } else if(customReEntity.getSort().equals("ASC")){
                sort = new Sort(Sort.Direction.ASC, customReEntity.getSortField());
            }
        }
        Pageable pageable = PageRequest.of(pageNumber,pageSize,sort);
        //动态查询条件
        Specification<CustomerRegistration> specification = (Specification<CustomerRegistration>)(root, query, criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (id != null) {
                Predicate p0 = criteriaBuilder.equal(root.get("receptionId"), id);
                list.add(p0);
            }
            Predicate p1 = criteriaBuilder.notEqual(root.get("isSystem"),1);
            list.add(p1);
            if (customReEntity.getsTime() != null && customReEntity.geteTime() != null){
                Predicate p2 = null;
                try {
                    p2 = criteriaBuilder.between(root.get("comeTime"),format.parse(customReEntity.getsTime()+" 23:59:59"),format.parse(customReEntity.geteTime()+" 23:59:59"));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                list.add(p2);
            }
            if (customReEntity.getCustomId() != null){
                Predicate p3 = criteriaBuilder.equal(root.get("id"),customReEntity.getCustomId());
                list.add(p3);
            }
            if (customReEntity.getLevel() != null){
                Predicate p4= criteriaBuilder.equal(root.get("level"),customReEntity.getLevel());
                list.add(p4);
            }
            if (customReEntity.getCustomerType() != null){
                Predicate p5= criteriaBuilder.equal(root.get("customerType"),customReEntity.getCustomerType());
                list.add(p5);
            }
            if (customReEntity.getHomeOwnership() != null){
                Predicate p6= criteriaBuilder.equal(root.get("homeOwnership"),customReEntity.getHomeOwnership());
                list.add(p6);
            }
            if (customReEntity.getAccessKnowledge() != null){
                Predicate p7= criteriaBuilder.equal(root.get("accessKnowledge"),customReEntity.getAccessKnowledge());
                list.add(p7);
            }
            if (customReEntity.getCustomerSource() != null){
                Predicate p8= criteriaBuilder.equal(root.get("customerSource"),customReEntity.getCustomerSource());
                list.add(p8);
            }
            return criteriaBuilder.and(list.toArray(new Predicate[0]));
        };
        Page<CustomerRegistration> lst = customerRegistrationRepository.findAll(specification, pageable);
        //查询来访记录信息
        for(CustomerRegistration customerRegistration : lst.getContent()){
            customerRegistration.setRecord(customerRegistrationRepository.queryCustomerRecordList(customerRegistration.getId()));
            customerRegistration.setLfNum(customerRegistration.getRecord().size());
        }
        return lst;
    }

    @Override
    public List<String> queryComeCustomerNum(Integer uid) {
        return customerRegistrationRepository.queryComeCustomerNum(uid);
    }

    @Override
    public List<String> myCustomerAnalysis(String time,Integer uid) {
        if (time == "0"){
            return customerRegistrationRepository.myCustomerAnalysisE(uid);
        }else{
            return customerRegistrationRepository.myCustomerAnalysis(time,uid);
        }
    }

    @Override
    public  List<String> myComeCustomer(String time,String areaCode,Integer uid){
        if (time == null && areaCode == null){
            return  customerRegistrationRepository.myComeCustomerZ(uid);
        }else if(time == null && areaCode != null){
            return  customerRegistrationRepository.myComeCustomerS(areaCode,uid);
        }else if(time != null && areaCode == null){
            return  customerRegistrationRepository.myComeCustomerE(time,uid);
        }else{
            return  customerRegistrationRepository.myComeCustomer(time,areaCode,uid);
        }
    }

    @Override
    public  List<Object> myConversionRate(String sTime,String eTime,Integer uid){
        return  customerRegistrationRepository.myConversionRateS(sTime,eTime,uid);
    }

    @Override
    public List<CustomerRegistration> getMyCustomerList(Integer userId,String A,String B,String C,String D) {
        return customerRegistrationRepository.getMyCustomerList(userId,A,B,C,D);
    }

    @Override
    public List<CustomerRegistration> getTeamCustomerList() {
        return customerRegistrationRepository.getTeamCustomerList();
    }

    @Override
    public void updateCustomerTime(String phones) {
        customerRegistrationRepository.updateCustomerTime(new Date(),phones);
    }

    @Override
    public List<String> queryTeamCustomerList(String sTime, String eTime,Integer uid) {
        return customerRegistrationRepository.queryTeamCustomerList(sTime,eTime,uid);
    }

    @Override
    public ArrayList<String> queryTeamRCustomerList(String sTime,String eTime,Integer uid) {
        return customerRegistrationRepository.queryTeamRCustomerList(sTime,eTime,uid);
    }

    @Override
    public List<Integer> queryMyCustomerListE(CustomReEntity customReEntity, Integer id) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        List<Integer> re = new ArrayList<>();
        int j = 0;
        //动态查询条件
        Specification<CustomerRegistration> specification = (Specification<CustomerRegistration>)(root, query, criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (id != null) {
                Predicate p0 = criteriaBuilder.equal(root.get("receptionId"), id);
                list.add(p0);
            }
            System.out.println("=-=================查询自己客户列表id======================>"+id);
            Predicate p1 = criteriaBuilder.notEqual(root.get("isSystem"),1);
            list.add(p1);
            if (customReEntity.getsTime() != null && customReEntity.geteTime() != null){
                Predicate p2 = null;
                try {
                    p2 = criteriaBuilder.between(root.get("comeTime"),format.parse(customReEntity.getsTime()),format.parse(customReEntity.geteTime()));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                list.add(p2);
            }
            if (customReEntity.getCustomId() != null){
                Predicate p3 = criteriaBuilder.equal(root.get("id"),customReEntity.getCustomId());
                list.add(p3);
            }
            if (customReEntity.getLevel() != null){
                Predicate p4= criteriaBuilder.equal(root.get("level"),customReEntity.getLevel());
                list.add(p4);
            }
            if (customReEntity.getCustomerType() != null){
                Predicate p5= criteriaBuilder.equal(root.get("customerType"),customReEntity.getCustomerType());
                list.add(p5);
            }
            Predicate p6= criteriaBuilder.equal(root.get("visit"),1);
            list.add(p6);
            if (customReEntity.getCustomerSource() != null){
                Predicate p7= criteriaBuilder.equal(root.get("customerSource"),customReEntity.getCustomerSource());
                list.add(p7);
            }
            //客户姓名或者手机号
            return criteriaBuilder.and(list.toArray(new Predicate[0]));
        };
        List<CustomerRegistration> lst = customerRegistrationRepository.findAll(specification);
        if (lst != null){
            //查询来访记录信息
            for(CustomerRegistration customerRegistration : lst){
                if (customerRegistration.getCustomerType().equals("大定")){
                    j = j + 1;
                }
                if (customerRegistration.getCustomerType().equals("已交首付")){
                    j = j + 1;
                }
                if (customerRegistration.getCustomerType().equals("已全款")){
                    j = j + 1;
                }
            }
        }
        re.add(lst.size());
        re.add(j);
        return re;
    }

    @Override
    public List<String> queryTeamECustomerList(String sTime, String eTime) {
        return customerRegistrationRepository.queryTeamECustomerList(sTime,eTime);
    }

    @Override
    public ArrayList<String> queryTeamERCustomerList(String sTime,String eTime) {
        return customerRegistrationRepository.queryTeamERCustomerList(sTime,eTime);
    }

    //我的客户销售分析
    @Override
    public JSONArray querySalesAnalysisOfMyCustomers(CustomReEntity customReEntity) {
        List yxd = new ArrayList<>();
        //我的成交客户分析
        if(customReEntity.getIsCj().equals("1")){
            List types = new ArrayList();
            List ids = new ArrayList();
            //物业类型
            if (customReEntity.getPropertyType() != null && !customReEntity.getPropertyType().equals("不限")){
                String ts = customReEntity.getPropertyType();
                String s[] = ts.split(",");
                for (String b : s){
                    types.add(b);
                }
            }
            //置业顾问id
            String uid = customReEntity.getReceptionId();
            String usId[] = uid.split(",");
            for (String id : usId){
                ids.add(id);
            }
            //我的客户意向度分析
            if (customReEntity.getUsrIntentionality() != null && customReEntity.getUsrIntentionality() != ""){
                HashMap map = new HashMap();
                Integer a = 0,b = 0,c = 0,d = 0,e = 0,f = 0;   //等级数
                List<Object> z = null;
                if (types.size() > 0){
                    z = customerRegistrationRepository.getUsrIntentionalityCj(customReEntity.getsTime(),customReEntity.geteTime(),ids,types);
                }else{
                    z = customerRegistrationRepository.getUsrIntentionalityCj(customReEntity.getsTime(),customReEntity.geteTime(),ids);
                }
                if (z.size() > 0){
                    for (int j = 0; j < z.size(); j++) {
                        Object[] objects = (Object[]) z.get(j);
                        if (objects[0].toString().equals("A")){
                            a++;
                        }else if (objects[0].toString().equals("B")){
                            b++;
                        }else if (objects[0].toString().equals("C")){
                            c++;
                        }else if (objects[0].toString().equals("D")){
                            d++;
                        }else if (objects[0].toString().equals("E")){
                            e++;
                        }else{
                            f++;
                        }
                    }
                }
                if (a > 0) {
                    map.put("A", a);
                }
                if (b > 0) {
                    map.put("B", b);
                }
                if (c > 0) {
                    map.put("C", c);
                }
                if (d > 0) {
                    map.put("D", d);
                }
                if (e > 0) {
                    map.put("E", e);
                }
                if (f > 0) {
                    map.put("未知", f);
                }
                yxd.add(map);
            }
            //购房目的
            if (customReEntity.getPurchasePurpose() != null && customReEntity.getPurchasePurpose() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getPurchasePurposeUs(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getPurchasePurposeUs(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户所在区域分析
            if (customReEntity.getAreaName() != null && customReEntity.getAreaName() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getAreaName(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getAreaName(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户到访次数
            if (customReEntity.getComeNum() != null && customReEntity.getComeNum() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getComeNum(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else {
                    yxd.add(customerRegistrationRepository.getComeNum(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户获知途径
            if (customReEntity.getAccessKnowledge() != null && customReEntity.getAccessKnowledge() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getAccessKnowledge(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getAccessKnowledge(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户置业次数
            if (customReEntity.getHomeOwnership() != null && customReEntity.getHomeOwnership() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getHomeOwnership(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getHomeOwnership(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户付款方式
            if (customReEntity.getPaymentType() != null && customReEntity.getPaymentType() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getPaymentType(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getPaymentType(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户考虑因素
            if (customReEntity.getConsiderType() != null && customReEntity.getConsiderType() != ""){
                HashMap map = new HashMap();
                Integer qy = 0, dd = 0, xq = 0, hx = 0, yl = 0, jt = 0, zj = 0, pt = 0, pp = 0, gh = 0, tz = 0, qt = 0;
                List<Object> a = null;
                if (types.size() > 0){
                    a = customerRegistrationRepository.qy(customReEntity.getsTime(), customReEntity.geteTime(), ids, types);
                }else{
                    a = customerRegistrationRepository.qy(customReEntity.getsTime(), customReEntity.geteTime(), ids);
                }
                if (a.size() > 0) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        String cid = objects[0].toString();
                        if (objects[0].toString().contains("区域")) {
                            qy++;
                        }
                        if (objects[0].toString().contains("地段")) {
                            dd++;
                        }
                        if (objects[0].toString().contains("学区")) {
                            xq++;
                        }
                        if (objects[0].toString().contains("户型")) {
                            hx++;
                        }
                        if (objects[0].toString().contains("园林")) {
                            yl++;
                        }
                        if (objects[0].toString().contains("交通")) {
                            jt++;
                        }
                        if (objects[0].toString().contains("总价")) {
                            zj++;
                        }
                        if (objects[0].toString().contains("配套")) {
                            pt++;
                        }
                        if (objects[0].toString().contains("品牌")) {
                            pp++;
                        }
                        if (objects[0].toString().contains("规划")) {
                            gh++;
                        }
                        if (objects[0].toString().contains("投资")) {
                            tz++;
                        }
                        if (objects[0].toString().contains("其它")) {
                            qt++;
                        }
                    }
                    if (qy > 0) {
                        map.put("区域", qy);
                    }
                    if (dd > 0) {
                        map.put("地段", qy);
                    }
                    if (xq > 0) {
                        map.put("学区", xq);
                    }
                    if (hx > 0) {
                        map.put("户型", hx);
                    }
                    if (yl > 0) {
                        map.put("园林", yl);
                    }
                    if (jt > 0) {
                        map.put("交通", jt);
                    }
                    if (zj > 0) {
                        map.put("总价", zj);
                    }
                    if (pt > 0) {
                        map.put("配套", pt);
                    }
                    if (pp > 0) {
                        map.put("品牌", pp);
                    }
                    if (gh > 0) {
                        map.put("规划", gh);
                    }
                    if (tz > 0) {
                        map.put("投资", tz);
                    }
                    if (qt > 0) {
                        map.put("其它", qt);
                    }
                }
                yxd.add(map);
            }
            //我的客户家庭结构
            if (customReEntity.getFamilyStructure() != null && customReEntity.getFamilyStructure() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getFamilyStructure(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getFamilyStructure(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户主要职业
            if (customReEntity.getCustomerOccupation() != null && customReEntity.getCustomerOccupation() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getCustomerOccupation(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getCustomerOccupation(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的成交客户购买户型
            if (customReEntity.getTypeOfClientele() != null && customReEntity.getTypeOfClientele() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getTypeOfClientele(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getTypeOfClientele(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户购买总价
            if (customReEntity.getTotalClientPrice() != null && customReEntity.getTotalClientPrice() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getTotalClientPrice(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getTotalClientPrice(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户退房原因
            if (customReEntity.getCheckOutReason() != null && customReEntity.getCheckOutReason() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getCheckOutReason(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getCheckOutReason(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户销售产品分析
            if (customReEntity.getPromotingProducts() != null && customReEntity.getPromotingProducts() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getPromotingProducts(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getPromotingProducts(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的销售数据统计
            /*if (customReEntity.getSalesStatistics() != null && customReEntity.getSalesStatistics() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getSalesStatistics(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getSalesStatistics(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }*/
            //我的销售转化率分析
            if (customReEntity.getSalesConversionRate() != null && customReEntity.getSalesConversionRate() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getSalesConversionRateT(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getSalesConversionRateT(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的成交客户销售状态
           /* if (customReEntity.getCustomerSalesStatus() != null && customReEntity.getCustomerSalesStatus() != ""){
                yxd.add(customerRegistrationRepository.getCustomerSalesStatus(customReEntity.getsTime(),customReEntity.geteTime(),customReEntity.getReceptionId(),types));
                //按两次数据获取 其中***
                yxd.add(customerRegistrationRepository.getAmong(customReEntity.getsTime(),customReEntity.geteTime(),customReEntity.getUserId(),types));
            }*/
            //物业类型  20191204
            //佣金待定
            //客户来源
            if (customReEntity.getCustomerSource() !=null){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getCustomerSource(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else {
                    yxd.add(customerRegistrationRepository.getCustomerSource(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //拒绝原因
            if (customReEntity.getRefuseReason() !=null){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getRefuseReason(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else{
                    yxd.add(customerRegistrationRepository.getRefuseReason(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //是否看过样板房
            if (customReEntity.getModelHouses() !=null){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getModelHouses(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }else {
                    yxd.add(customerRegistrationRepository.getModelHouses(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }
            }
            //我的客户意向户型
            if (customReEntity.getIntentionalHouseholdType() != null && customReEntity.getIntentionalHouseholdType() != ""){
                if (types.size() > 0){
                    yxd.add(customerRegistrationRepository.getIntentionalHouseholdType(customReEntity.getsTime(), customReEntity.geteTime(), ids, types));
                }else{
                    yxd.add(customerRegistrationRepository.getIntentionalHouseholdTypeE(customReEntity.getsTime(), customReEntity.geteTime(), ids));
                }
            }
        }else if (customReEntity.getIsCj().equals("0")){
            //我的未成交客户分析
            List typesE = new ArrayList();
            List idsS = new ArrayList();
            if (customReEntity.getPropertyType() != null && !customReEntity.getPropertyType().equals("不限")){
                String ts = customReEntity.getPropertyType();
                String s[] = ts.split(",");
                for (String b : s){
                    typesE.add(b);
                }
            }
            String uid = customReEntity.getReceptionId();
            String usId[] = uid.split(",");
            for (String id : usId){
                idsS.add(id);
            }
            //我的客户意向度分析
            if (customReEntity.getUsrIntentionality() != null && customReEntity.getUsrIntentionality() != ""){
                HashMap map = new HashMap();
                Integer a = 0,b = 0,c = 0,d = 0,e = 0,f = 0;   //等级数
                List<Object> z = null;
                if (typesE.size() > 0){
                    z = customerRegistrationRepository.getUsrIntentionalityWCj(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE);
                }else{
                    z = customerRegistrationRepository.getUsrIntentionalityWCj(customReEntity.getsTime(),customReEntity.geteTime(),idsS);
                }
                if (z.size() > 0){
                    for (int j = 0; j < z.size(); j++) {
                        Object[] objects = (Object[]) z.get(j);
                        if (objects[0].toString().equals("A")){
                            a++;
                        }else if (objects[0].toString().equals("B")){
                            b++;
                        }else if (objects[0].toString().equals("C")){
                            c++;
                        }else if (objects[0].toString().equals("D")){
                            d++;
                        }else if (objects[0].toString().equals("E")){
                            e++;
                        }else{
                            f++;
                        }
                    }
                }
                if (a > 0) {
                    map.put("A", a);
                }
                if (b > 0) {
                    map.put("B", b);
                }
                if (c > 0) {
                    map.put("C", c);
                }
                if (d > 0) {
                    map.put("D", d);
                }
                if (e > 0) {
                    map.put("E", e);
                }
                if (f > 0) {
                    map.put("未知", f);
                }
                yxd.add(map);
            }
            //购房目的
            if (customReEntity.getPurchasePurpose() != null && customReEntity.getPurchasePurpose() != ""){
                if (typesE.size() > 0){
                    yxd.add(customerRegistrationRepository.getPurchasePurposeW(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getPurchasePurposeW(customReEntity.getsTime(),customReEntity.geteTime(),idsS));
                }
            }
            //我的客户所在区域分析
            if (customReEntity.getAreaName() != null && customReEntity.getAreaName() != ""){
                if (typesE.size() > 0){
                    yxd.add(customerRegistrationRepository.getAreaNameW(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getAreaNameW(customReEntity.getsTime(),customReEntity.geteTime(),idsS));
                }
            }
            //我的客户到访次数
            if (customReEntity.getComeNum() != null && customReEntity.getComeNum() != ""){
                if (typesE.size() > 0) {
                    yxd.add(customerRegistrationRepository.getComeNumW(customReEntity.getsTime(), customReEntity.geteTime(),idsS,typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getComeNumW(customReEntity.getsTime(), customReEntity.geteTime(), idsS));
                }
            }
            //我的客户获知途径
            if (customReEntity.getAccessKnowledge() != null && customReEntity.getAccessKnowledge() != ""){
                if (typesE.size() > 0) {
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeW(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeW(customReEntity.getsTime(),customReEntity.geteTime(),idsS));
                }
            }
            //我的客户面积需求
            if (customReEntity.getAreaNeed() != null && customReEntity.getAreaNeed() != "") {
                HashMap map = new HashMap();
                List<Object> a = null;
                Integer lsf = 0, bsf = 0, ybf = 0, ybef = 0, ybsf = 0, yblf = 0, ybjf = 0, ebwf = 0, sbf = 0, ssbf = 0, wbf = 0, wbysf = 0;
                if (typesE.size() > 0) {
                    a = customerRegistrationRepository.getAreaNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsS, typesE);
                }else{
                    a = customerRegistrationRepository.getAreaNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsS);
                }
                    if (a.size() > 0) {
                        for (int j = 0; j < a.size(); j++) {
                            Object[] objects = (Object[]) a.get(j);
                            if (objects[0].toString().contains("60方以下")) {
                                lsf++;
                            }
                            if (objects[0].toString().contains("61-89方")) {
                                bsf++;
                            }
                            if (objects[0].toString().contains("90-100方")) {
                                ybf++;
                            }
                            if (objects[0].toString().contains("100-120方")) {
                                ybef++;
                            }
                            if (objects[0].toString().contains("121-140方")) {
                                ybsf++;
                            }
                            if (objects[0].toString().contains("140-160方")) {
                                yblf++;
                            }
                            if (objects[0].toString().contains("161-195方")) {
                                ybjf++;
                            }
                            if (objects[0].toString().contains("196-250方")) {
                                ebwf++;
                            }
                            if (objects[0].toString().contains("251-300方")) {
                                sbf++;
                            }
                            if (objects[0].toString().contains("301-400方")) {
                                ssbf++;
                            }
                            if (objects[0].toString().contains("401-500方")) {
                                wbf++;
                            }
                            if (objects[0].toString().contains("500以上")) {
                                wbysf++;
                            }
                        }
                        if (lsf > 0) {
                            map.put("60方以下", lsf);
                        }
                        if (bsf > 0) {
                            map.put("61-89方", bsf);
                        }
                        if (ybf > 0) {
                            map.put("90-100方", ybf);
                        }
                        if (ybef > 0) {
                            map.put("100-120方", ybef);
                        }
                        if (ybsf > 0) {
                            map.put("121-140方", ybsf);
                        }
                        if (yblf > 0) {
                            map.put("140-160方", yblf);
                        }
                        if (ybjf > 0) {
                            map.put("161-195方", ybjf);
                        }
                        if (ebwf > 0) {
                            map.put("196-250方", ebwf);
                        }
                        if (sbf > 0) {
                            map.put("251-300方", sbf);
                        }
                        if (ssbf > 0) {
                            map.put("301-400方", ssbf);
                        }
                        if (wbf > 0) {
                            map.put("401-500方", wbf);
                        }
                        if (wbysf > 0) {
                            map.put("500以上", wbysf);
                        }
                        yxd.add(map);
                }
            }
            //我的客户意向户型
            /*if (customReEntity.getIntentionalHouseholdType() != null && customReEntity.getIntentionalHouseholdType() != ""){
                if (customReEntity.getLevel() != null && customReEntity.getLevel() != "") {
                    yxd.add(customerRegistrationRepository.getIntentionalHouseholdType(customReEntity.getsTime(), customReEntity.geteTime(), idsS, typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getIntentionalHouseholdTypeE(customReEntity.getsTime(), customReEntity.geteTime(), idsS));
                }
            }*/
            //我的客户年龄分析
            if (customReEntity.getAge() != null){
                //20191202
                HashMap hs = new HashMap();
                Integer qt = 0,es = 0,ss = 0,sw = 0,wl = 0;
                List<Object> nld = null;
                if (typesE.size() > 0) {
                    nld = customerRegistrationRepository.getAgeW(customReEntity.getsTime(), customReEntity.geteTime(), idsS, typesE);
                }else{
                    nld = customerRegistrationRepository.getAgeW(customReEntity.getsTime(), customReEntity.geteTime(), idsS);
                }
                    if (nld.size() > 0){
                        for (int k =0;k<nld.size();k++){
                            Object[] objects = (Object[])nld.get(k);
                            if (Integer.valueOf(objects[0].toString()) > 0 && Integer.valueOf(objects[0].toString()) < 20) {
                                qt++; //其它
                            }
                            if (Integer.valueOf(objects[0].toString()) >= 20 && Integer.valueOf(objects[0].toString()) < 30) {
                                es++; //20-30
                            }
                            if (Integer.valueOf(objects[0].toString()) >= 30 && Integer.valueOf(objects[0].toString()) < 40) {
                                ss++; //30-40
                            }
                            if (Integer.valueOf(objects[0].toString()) >= 40 && Integer.valueOf(objects[0].toString()) < 50) {
                                sw++; //40-50
                            }
                            if (Integer.valueOf(objects[0].toString()) >= 50 && Integer.valueOf(objects[0].toString()) < 60) {
                                wl++; //50-60
                            }
                            if (Integer.valueOf(objects[0].toString()) > 60) {
                                qt++; //其它
                            }
                        }
                        if (qt > 0) {
                            hs.put("其它", qt);
                        }
                        if (es > 0) {
                            hs.put("20-30岁", es);
                        }
                        if (ss > 0) {
                            hs.put("30-40岁", ss);
                        }
                        if (sw > 0) {
                            hs.put("40-50岁", sw);
                        }
                        if (wl > 0) {
                            hs.put("50-60岁", wl);
                        }
                        yxd.add(hs);
                    }
            }
            //我的客户总价需求
            if (customReEntity.getTotalNeed() != null && customReEntity.getTotalNeed() != "") {
                //20191127
                HashMap map = new HashMap();
                List<Object> a = null;
                Integer ybw = 0, ybww = 0, ebw = 0, sbw = 0, ssbw = 0, wbw = 0, qbw = 0, qbwys = 0;
                if (typesE.size() > 0) {
                    a = customerRegistrationRepository.getTotalNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsS, typesE);
                }else{
                    a = customerRegistrationRepository.getTotalNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsS);
                }
                    if (a.size() > 0) {
                        for (int j = 0; j < a.size(); j++) {
                            Object[] objects = (Object[]) a.get(j);
                            if (objects[0].toString().contains("100万以下")) {
                                ybw++;
                            }
                            if (objects[0].toString().contains("100-150万")) {
                                ybww++;
                            }
                            if (objects[0].toString().contains("151-200万")) {
                                ebw++;
                            }
                            if (objects[0].toString().contains("200-300万")) {
                                sbw++;
                            }
                            if (objects[0].toString().contains("300-400万")) {
                                ssbw++;
                            }
                            if (objects[0].toString().contains("400-500万")) {
                                wbw++;
                            }
                            if (objects[0].toString().contains("500-700万")) {
                                qbw++;
                            }
                            if (objects[0].toString().contains("700万以上")) {
                                qbwys++;
                            }
                        }
                        if (ybw > 0) {
                            map.put("100万以下", ybw);
                        }
                        if (ybww > 0) {
                            map.put("100-150万", ybww);
                        }
                        if (ebw > 0) {
                            map.put("151-200万", ebw);
                        }
                        if (sbw > 0) {
                            map.put("200-300万", sbw);
                        }
                        if (ssbw > 0) {
                            map.put("300-400万", ssbw);
                        }
                        if (wbw > 0) {
                            map.put("400-500万", wbw);
                        }
                        if (qbw > 0) {
                            map.put("500-700万", qbw);
                        }
                        if (qbwys > 0) {
                            map.put("700万以上", qbwys);
                        }
                        yxd.add(map);
                    }
                    yxd.add(map);
            }
            //我的客户付款方式
            if (customReEntity.getPaymentType() != null && customReEntity.getPaymentType() != ""){
                if (typesE.size() > 0) {
                    yxd.add(customerRegistrationRepository.getPaymentTypeW(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getPaymentTypeW(customReEntity.getsTime(), customReEntity.geteTime(), idsS));
                }
            }
            //我的客户价格接受度
            if (customReEntity.getPriceAcceptance() != null && customReEntity.getPriceAcceptance() != ""){
                if (typesE.size() > 0) {
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceW(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceW(customReEntity.getsTime(), customReEntity.geteTime(), idsS));
                }
            }
            //我的客户考虑因素
            if (customReEntity.getConsiderType() != null && customReEntity.getConsiderType() != "") {
                HashMap map = new HashMap();
                List<Object> a = null;
                        Integer qy = 0, dd = 0, xq = 0, hx = 0, yl = 0, jt = 0, zj = 0, pt = 0, pp = 0, gh = 0, tz = 0, qt = 0;
                if (typesE.size() > 0) {
                    a = customerRegistrationRepository.qyW(customReEntity.getsTime(), customReEntity.geteTime(), idsS, typesE);
                }else {
                    a = customerRegistrationRepository.qyW(customReEntity.getsTime(), customReEntity.geteTime(),idsS);
                }
                    if (a.size() > 0) {
                        for (int j = 0; j < a.size(); j++) {
                            Object[] objects = (Object[]) a.get(j);
                            String cid = objects[0].toString();
                            if (objects[0].toString().contains("区域")) {
                                qy++;
                            }
                            if (objects[0].toString().contains("地段")) {
                                dd++;
                            }
                            if (objects[0].toString().contains("学区")) {
                                xq++;
                            }
                            if (objects[0].toString().contains("户型")) {
                                hx++;
                            }
                            if (objects[0].toString().contains("园林")) {
                                yl++;
                            }
                            if (objects[0].toString().contains("交通")) {
                                jt++;
                            }
                            if (objects[0].toString().contains("总价")) {
                                zj++;
                            }
                            if (objects[0].toString().contains("配套")) {
                                pt++;
                            }
                            if (objects[0].toString().contains("品牌")) {
                                pp++;
                            }
                            if (objects[0].toString().contains("规划")) {
                                gh++;
                            }
                            if (objects[0].toString().contains("投资")) {
                                tz++;
                            }
                            if (objects[0].toString().contains("其它")) {
                                qt++;
                            }
                        }
                        if (qy > 0) {
                            map.put("区域", qy);
                        }
                        if (dd > 0) {
                            map.put("地段", qy);
                        }
                        if (xq > 0) {
                            map.put("学区", xq);
                        }
                        if (hx > 0) {
                            map.put("户型", hx);
                        }
                        if (yl > 0) {
                            map.put("园林", yl);
                        }
                        if (jt > 0) {
                            map.put("交通", jt);
                        }
                        if (zj > 0) {
                            map.put("总价", zj);
                        }
                        if (pt > 0) {
                            map.put("配套", pt);
                        }
                        if (pp > 0) {
                            map.put("品牌", pp);
                        }
                        if (gh > 0) {
                            map.put("规划", gh);
                        }
                        if (tz > 0) {
                            map.put("投资", tz);
                        }
                        if (qt > 0) {
                            map.put("其它", qt);
                        }
                        yxd.add(map);
                }
            }
            //我的客户户型需求
            if (customReEntity.getHouseTypeNeed() != null && customReEntity.getHouseTypeNeed() != ""){
                HashMap map = new HashMap();
                Integer yf = 0,ef = 0,sfyw = 0,sflw = 0,ssfyw =0,ssflw =0,wf = 0,lfys = 0;
                List<Object> a = null;
                if (typesE.size() > 0) {
                    a = customerRegistrationRepository.getHouseTypeNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsS, typesE);
                }else {
                    a = customerRegistrationRepository.getHouseTypeNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsS);
                }
                    if (a.size() > 0) {
                        for (int j = 0; j < a.size(); j++) {
                            Object[] objects = (Object[]) a.get(j);
                            if (objects[0].toString().contains("一房")) {
                                yf++;
                            }
                            if (objects[0].toString().contains("二房")) {
                                ef++;
                            }
                            if (objects[0].toString().contains("三房一卫")) {
                                sfyw++;
                            }
                            if (objects[0].toString().contains("三房两卫")) {
                                sflw++;
                            }
                            if (objects[0].toString().contains("四房一卫")) {
                                ssfyw++;
                            }
                            if (objects[0].toString().contains("四房两卫")) {
                                ssflw++;
                            }
                            if (objects[0].toString().contains("五房")) {
                                wf++;
                            }
                            if (objects[0].toString().contains("六房及以上")) {
                                lfys++;
                            }
                        }
                        if (yf > 0) {
                            map.put("一房", yf);
                        }
                        if (ef > 0) {
                            map.put("二房", ef);
                        }
                        if (sfyw > 0) {
                            map.put("三房一卫", sfyw);
                        }
                        if (sflw > 0) {
                            map.put("三房两卫", sflw);
                        }
                        if (ssfyw > 0) {
                            map.put("四房一卫", ssfyw);
                        }
                        if (ssflw > 0) {
                            map.put("四房两卫", ssflw);
                        }
                        if (wf > 0) {
                            map.put("五房", wf);
                        }
                        if (lfys > 0) {
                            map.put("六房及以上", lfys);
                        }
                        yxd.add(map);
                }
            }
            //我的客户家庭结构
            if (customReEntity.getFamilyStructure() != null && customReEntity.getFamilyStructure() != ""){
                if (typesE.size() > 0) {
                    yxd.add(customerRegistrationRepository.getFamilyStructureW(customReEntity.getsTime(), customReEntity.geteTime(), idsS, typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getFamilyStructureW(customReEntity.getsTime(), customReEntity.geteTime(), idsS));
                }
            }
            //我的客户置业次数
            if (customReEntity.getHomeOwnership() != null && customReEntity.getHomeOwnership() != ""){
                if (typesE.size() > 0) {
                    yxd.add(customerRegistrationRepository.getHomeOwnershipW(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getHomeOwnershipW(customReEntity.getsTime(),customReEntity.geteTime(),idsS));
                }
            }
            //我的客户主要职业
            if (customReEntity.getCustomerOccupation() != null && customReEntity.getCustomerOccupation() != ""){
                if (typesE.size() > 0) {
                    yxd.add(customerRegistrationRepository.getCustomerOccupationW(customReEntity.getsTime(), customReEntity.geteTime(), idsS, typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getCustomerOccupationW(customReEntity.getsTime(), customReEntity.geteTime(), idsS));
                }
            }
            //客户来源
            if (customReEntity.getCustomerSource() !=null){
                if (typesE.size() > 0){
                    yxd.add(customerRegistrationRepository.getCustomerSourceM(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else{
                    yxd.add(customerRegistrationRepository.getCustomerSourceM(customReEntity.getsTime(),customReEntity.geteTime(),idsS));
                }
            }
            //拒绝原因
            if (customReEntity.getRefuseReason() !=null){
                if (typesE.size() > 0){
                    yxd.add(customerRegistrationRepository.getRefuseReasonM(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else {
                    yxd.add(customerRegistrationRepository.getRefuseReasonM(customReEntity.getsTime(),customReEntity.geteTime(),idsS));
                }
            }
            //是否看过样板房
            if (customReEntity.getModelHouses() !=null){
                if (typesE.size() > 0){
                    yxd.add(customerRegistrationRepository.getModelHousesM(customReEntity.getsTime(),customReEntity.geteTime(),idsS,typesE));
                }else {
                    yxd.add(customerRegistrationRepository.getModelHousesM(customReEntity.getsTime(),customReEntity.geteTime(),idsS));
                }
            }
        }else{
            List typesAll = new ArrayList();
            List idsAll = new ArrayList();
            if (customReEntity.getPropertyType() != null && !customReEntity.getPropertyType().equals("不限")){
                String ts = customReEntity.getPropertyType();
                String s[] = ts.split(",");
                for (String b : s){
                    typesAll.add(b);
                }
            }
            String uid = customReEntity.getReceptionId();
            String usId[] = uid.split(",");
            for (String id : usId){
                idsAll.add(id);
            }
            //我的客户意向度分析
            if (customReEntity.getUsrIntentionality() != null && customReEntity.getUsrIntentionality() != ""){
                HashMap map = new HashMap();
                Integer a = 0,b = 0,c = 0,d = 0,e = 0,f = 0;   //等级数
                List<Object> z = null;
                if (typesAll.size() > 0){
                    z = customerRegistrationRepository.getUsrIntentionalityAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll);
                }else{
                    z = customerRegistrationRepository.getUsrIntentionalityAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll);
                }
                if (z.size() > 0){
                    for (int j = 0; j < z.size(); j++) {
                        Object[] objects = (Object[]) z.get(j);
                        if (objects[0].toString().equals("A")){
                            a++;
                        }else if (objects[0].toString().equals("B")){
                            b++;
                        }else if (objects[0].toString().equals("C")){
                            c++;
                        }else if (objects[0].toString().equals("D")){
                            d++;
                        }else if (objects[0].toString().equals("E")){
                            e++;
                        }else{
                            f++;
                        }
                    }
                }
                if (a > 0) {
                    map.put("A", a);
                }
                if (b > 0) {
                    map.put("B", b);
                }
                if (c > 0) {
                    map.put("C", c);
                }
                if (d > 0) {
                    map.put("D", d);
                }
                if (e > 0) {
                    map.put("E", e);
                }
                if (f > 0) {
                    map.put("未知", f);
                }
                yxd.add(map);
            }
            //购房目的
            if (customReEntity.getPurchasePurpose() != null){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getPurchasePurposeAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else {
                    yxd.add(customerRegistrationRepository.getPurchasePurposeAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //所在区域
            if (customReEntity.getAreaName() != null){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getAreaNameAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else {
                    yxd.add(customerRegistrationRepository.getAreaNameAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //到访次数
            if (customReEntity.getComeNum() != null){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getComeNumAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else{
                    yxd.add(customerRegistrationRepository.getComeNumAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //获知途径
            if (customReEntity.getAccessKnowledge() != null){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else{
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //面积需求
            if (customReEntity.getAreaNeed() != null){
                List<Object> a = null;
                HashMap map = new HashMap();
                Integer lsf = 0, bsf = 0, ybf = 0, ybef = 0, ybsf = 0, yblf = 0, ybjf = 0, ebwf = 0, sbf = 0, ssbf = 0, wbf = 0, wbysf = 0;
                if (typesAll.size() > 0){
                    a = customerRegistrationRepository.getAreaNeedDxAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll);
                }else{
                    a= customerRegistrationRepository.getAreaNeedDxAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll);
                }
                if (a.size() > 0) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("60方以下")) {
                            lsf++;
                        }
                        if (objects[0].toString().contains("61-89方")) {
                            bsf++;
                        }
                        if (objects[0].toString().contains("90-100方")) {
                            ybf++;
                        }
                        if (objects[0].toString().contains("100-120方")) {
                            ybef++;
                        }
                        if (objects[0].toString().contains("121-140方")) {
                            ybsf++;
                        }
                        if (objects[0].toString().contains("140-160方")) {
                            yblf++;
                        }
                        if (objects[0].toString().contains("161-195方")) {
                            ybjf++;
                        }
                        if (objects[0].toString().contains("196-250方")) {
                            ebwf++;
                        }
                        if (objects[0].toString().contains("251-300方")) {
                            sbf++;
                        }
                        if (objects[0].toString().contains("301-400方")) {
                            ssbf++;
                        }
                        if (objects[0].toString().contains("401-500方")) {
                            wbf++;
                        }
                        if (objects[0].toString().contains("500以上")) {
                            wbysf++;
                        }
                    }
                    if (lsf > 0) {
                        map.put("60方以下", lsf);
                    }
                    if (bsf > 0) {
                        map.put("61-89方", bsf);
                    }
                    if (ybf > 0) {
                        map.put("90-100方", ybf);
                    }
                    if (ybef > 0) {
                        map.put("100-120方", ybef);
                    }
                    if (ybsf > 0) {
                        map.put("121-140方", ybsf);
                    }
                    if (yblf > 0) {
                        map.put("140-160方", yblf);
                    }
                    if (ybjf > 0) {
                        map.put("161-195方", ybjf);
                    }
                    if (ebwf > 0) {
                        map.put("196-250方", ebwf);
                    }
                    if (sbf > 0) {
                        map.put("251-300方", sbf);
                    }
                    if (ssbf > 0) {
                        map.put("301-400方", ssbf);
                    }
                    if (wbf > 0) {
                        map.put("401-500方", wbf);
                    }
                    if (wbysf > 0) {
                        map.put("500以上", wbysf);
                    }
                    yxd.add(map);
                }
            }
            //年龄段
            if (customReEntity.getAge() != null){
                //20191205
                HashMap hs = new HashMap();
                Integer qt = 0,es = 0,ss = 0,sw = 0,wl = 0;
                List<Object> nld = null;
                if (typesAll.size() > 0) {
                    nld = customerRegistrationRepository.getAgeAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll, typesAll);
                }else{
                    nld = customerRegistrationRepository.getAgeAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                }
                if (nld.size() > 0){
                    for (int k =0;k<nld.size();k++){
                        Object[] objects = (Object[])nld.get(k);
                        if (Integer.valueOf(objects[0].toString()) > 0 && Integer.valueOf(objects[0].toString()) < 20) {
                            qt++; //其它
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 20 && Integer.valueOf(objects[0].toString()) < 30) {
                            es++; //20-30
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 30 && Integer.valueOf(objects[0].toString()) < 40) {
                            ss++; //30-40
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 40 && Integer.valueOf(objects[0].toString()) < 50) {
                            sw++; //40-50
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 50 && Integer.valueOf(objects[0].toString()) < 60) {
                            wl++; //50-60
                        }
                        if (Integer.valueOf(objects[0].toString()) > 60) {
                            qt++; //其它
                        }
                    }
                    if (qt > 0) {
                        hs.put("其它", qt);
                    }
                    if (es > 0) {
                        hs.put("20-30岁", es);
                    }
                    if (ss > 0) {
                        hs.put("30-40岁", ss);
                    }
                    if (sw > 0) {
                        hs.put("40-50岁", sw);
                    }
                    if (wl > 0) {
                        hs.put("50-60岁", wl);
                    }
                    yxd.add(hs);
                }
            }
            //置业次数
            if (customReEntity.getHomeOwnership() != null){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getHomeOwnershipAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else {
                    yxd.add(customerRegistrationRepository.getHomeOwnershipAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //总价需求
            if (customReEntity.getTotalNeed() != null && customReEntity.getTotalNeed() != "") {
                //20191205
                HashMap map = new HashMap();
                List<Object> a = null;
                Integer ybw = 0, ybww = 0, ebw = 0, sbw = 0, ssbw = 0, wbw = 0, qbw = 0, qbwys = 0;
                if (typesAll.size() > 0) {
                    a = customerRegistrationRepository.getTotalNeedDxAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll,typesAll);
                }else{
                    a = customerRegistrationRepository.getTotalNeedDxAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                }
                if (a.size() > 0) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("100万以下")) {
                            ybw++;
                        }
                        if (objects[0].toString().contains("100-150万")) {
                            ybww++;
                        }
                        if (objects[0].toString().contains("151-200万")) {
                            ebw++;
                        }
                        if (objects[0].toString().contains("200-300万")) {
                            sbw++;
                        }
                        if (objects[0].toString().contains("300-400万")) {
                            ssbw++;
                        }
                        if (objects[0].toString().contains("400-500万")) {
                            wbw++;
                        }
                        if (objects[0].toString().contains("500-700万")) {
                            qbw++;
                        }
                        if (objects[0].toString().contains("700万以上")) {
                            qbwys++;
                        }
                    }
                    if (ybw > 0) {
                        map.put("100万以下", ybw);
                    }
                    if (ybww > 0) {
                        map.put("100-150万", ybww);
                    }
                    if (ebw > 0) {
                        map.put("151-200万", ebw);
                    }
                    if (sbw > 0) {
                        map.put("200-300万", sbw);
                    }
                    if (ssbw > 0) {
                        map.put("300-400万", ssbw);
                    }
                    if (wbw > 0) {
                        map.put("400-500万", wbw);
                    }
                    if (qbw > 0) {
                        map.put("500-700万", qbw);
                    }
                    if (qbwys > 0) {
                        map.put("700万以上", qbwys);
                    }
                    yxd.add(map);
                }
                yxd.add(map);
            }
            //价格接受度
            if (customReEntity.getPriceAcceptance() != null && customReEntity.getPriceAcceptance() != ""){
                if (typesAll.size() > 0) {
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else{
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                }
            }
            //考虑因素
            if (customReEntity.getConsiderType() != null && customReEntity.getConsiderType() != ""){
                HashMap map = new HashMap();
                Integer qy = 0, dd = 0, xq = 0, hx = 0, yl = 0, jt = 0, zj = 0, pt = 0, pp = 0, gh = 0, tz = 0, qt = 0;
                List<Object> a = null;
                if (typesAll.size() > 0){
                    a = customerRegistrationRepository.qyAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll,typesAll);
                }else{
                    a = customerRegistrationRepository.qyAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                }
                if (a.size() > 0) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        String cid = objects[0].toString();
                        if (objects[0].toString().contains("区域")) {
                            qy++;
                        }
                        if (objects[0].toString().contains("地段")) {
                            dd++;
                        }
                        if (objects[0].toString().contains("学区")) {
                            xq++;
                        }
                        if (objects[0].toString().contains("户型")) {
                            hx++;
                        }
                        if (objects[0].toString().contains("园林")) {
                            yl++;
                        }
                        if (objects[0].toString().contains("交通")) {
                            jt++;
                        }
                        if (objects[0].toString().contains("总价")) {
                            zj++;
                        }
                        if (objects[0].toString().contains("配套")) {
                            pt++;
                        }
                        if (objects[0].toString().contains("品牌")) {
                            pp++;
                        }
                        if (objects[0].toString().contains("规划")) {
                            gh++;
                        }
                        if (objects[0].toString().contains("投资")) {
                            tz++;
                        }
                        if (objects[0].toString().contains("其它")) {
                            qt++;
                        }
                    }
                    if (qy > 0) {
                        map.put("区域", qy);
                    }
                    if (dd > 0) {
                        map.put("地段", qy);
                    }
                    if (xq > 0) {
                        map.put("学区", xq);
                    }
                    if (hx > 0) {
                        map.put("户型", hx);
                    }
                    if (yl > 0) {
                        map.put("园林", yl);
                    }
                    if (jt > 0) {
                        map.put("交通", jt);
                    }
                    if (zj > 0) {
                        map.put("总价", zj);
                    }
                    if (pt > 0) {
                        map.put("配套", pt);
                    }
                    if (pp > 0) {
                        map.put("品牌", pp);
                    }
                    if (gh > 0) {
                        map.put("规划", gh);
                    }
                    if (tz > 0) {
                        map.put("投资", tz);
                    }
                    if (qt > 0) {
                        map.put("其它", qt);
                    }
                }
                yxd.add(map);
            }
            //户型需求
            if (customReEntity.getHouseTypeNeed() != null && customReEntity.getHouseTypeNeed() != ""){
                HashMap map = new HashMap();
                Integer yf = 0,ef = 0,sfyw = 0,sflw = 0,ssfyw =0,ssflw =0,wf = 0,lfys = 0;
                List<Object> a = null;
                if (typesAll.size() > 0) {
                    a = customerRegistrationRepository.getHouseTypeNeedDxAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll, typesAll);
                }else {
                    a = customerRegistrationRepository.getHouseTypeNeedDxAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                }
                if (a.size() > 0) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("一房")) {
                            yf++;
                        }
                        if (objects[0].toString().contains("二房")) {
                            ef++;
                        }
                        if (objects[0].toString().contains("三房一卫")) {
                            sfyw++;
                        }
                        if (objects[0].toString().contains("三房两卫")) {
                            sflw++;
                        }
                        if (objects[0].toString().contains("四房一卫")) {
                            ssfyw++;
                        }
                        if (objects[0].toString().contains("四房两卫")) {
                            ssflw++;
                        }
                        if (objects[0].toString().contains("五房")) {
                            wf++;
                        }
                        if (objects[0].toString().contains("六房及以上")) {
                            lfys++;
                        }
                    }
                    if (yf > 0) {
                        map.put("一房", yf);
                    }
                    if (ef > 0) {
                        map.put("二房", ef);
                    }
                    if (sfyw > 0) {
                        map.put("三房一卫", sfyw);
                    }
                    if (sflw > 0) {
                        map.put("三房两卫", sflw);
                    }
                    if (ssfyw > 0) {
                        map.put("四房一卫", ssfyw);
                    }
                    if (ssflw > 0) {
                        map.put("四房两卫", ssflw);
                    }
                    if (wf > 0) {
                        map.put("五房", wf);
                    }
                    if (lfys > 0) {
                        map.put("六房及以上", lfys);
                    }
                    yxd.add(map);
                }
            }
            //家庭结构
            if (customReEntity.getFamilyStructure() != null && customReEntity.getFamilyStructure() != ""){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getFamilyStructureAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else{
                    yxd.add(customerRegistrationRepository.getFamilyStructureAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //客户职业
            if (customReEntity.getCustomerOccupation() != null && customReEntity.getCustomerOccupation() != ""){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getCustomerOccupationAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else{
                    yxd.add(customerRegistrationRepository.getCustomerOccupationAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //客户来源
            if (customReEntity.getCustomerSource() !=null){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getCustomerSourceAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else {
                    yxd.add(customerRegistrationRepository.getCustomerSourceAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //拒绝原因
            if (customReEntity.getRefuseReason() !=null){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getRefuseReasonAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else{
                    yxd.add(customerRegistrationRepository.getRefuseReasonAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
            //是否看过样板房
            if (customReEntity.getModelHouses() !=null){
                if (typesAll.size() > 0){
                    yxd.add(customerRegistrationRepository.getModelHousesAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }else {
                    yxd.add(customerRegistrationRepository.getModelHousesAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll));
                }
            }
        }
        JSONArray jsonArray=new JSONArray(yxd);
        return jsonArray;
    }

    @Override
    public Page<CustomerRegistration> teamCustomerList(CustomReEntity customReEntity) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Integer pageNumber = customReEntity.getPageNumber()-1;
        Integer pageSize = customReEntity.getPageSize();
        // 排序条件 默认最新
        Sort sort = new Sort(Sort.Direction.DESC, "id");
        if(customReEntity.getSort() != null){
            if (customReEntity.getSort().equals("DESC")) {
                sort = new Sort(Sort.Direction.DESC, customReEntity.getSortField());
            } else if(customReEntity.getSort().equals("ASC")){
                sort = new Sort(Sort.Direction.ASC, customReEntity.getSortField());
            }
        }
        Pageable pageable = PageRequest.of(pageNumber,pageSize,sort);
        //动态查询条件
        Specification<CustomerRegistration> specification = (Specification<CustomerRegistration>)(root, query, criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            Predicate p0 = criteriaBuilder.notEqual(root.get("isSystem"),1);
            list.add(p0);
            if (customReEntity.getsTime() != null && customReEntity.geteTime() != null){
                Predicate p1= null;
                try {
                    p1 = criteriaBuilder.between(root.get("comeTime"),format.parse(customReEntity.getsTime()),format.parse(customReEntity.geteTime()));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                list.add(p1);
            }
            if (customReEntity.getCustomId() != null){
                //客户id查询
                Predicate p2 = criteriaBuilder.equal(root.get("id"),customReEntity.getCustomId());
                list.add(p2);
            }
            if (customReEntity.getLevel() != null){
                //客户等级查询
                Predicate p3= criteriaBuilder.equal(root.get("level"),customReEntity.getLevel());
                list.add(p3);
            }
            if (customReEntity.getCustomerType() != null){
                //客户状态
                Predicate p4= criteriaBuilder.equal(root.get("customerType"),customReEntity.getCustomerType());
                list.add(p4);
            }
            if (customReEntity.getReceptionId() != null){
                List ids = new ArrayList();
                String zy[] = customReEntity.getReceptionId().split(",");
                for (String id : zy){
                    ids.add(Integer.valueOf(id));
                }
                //置业顾问
                Path<Object> p5 = root.get("receptionId");//定义查询的字段
                CriteriaBuilder.In<Object> in = criteriaBuilder.in(p5);
                for (int i = 0; i <ids.size() ; i++) {
                    in.value(ids.get(i));//存入值
                }
                list.add(criteriaBuilder.and(criteriaBuilder.and(in)));//存入条件集合里
            }
            if(customReEntity.getName() != null){
                //客户姓名
                Predicate p6= criteriaBuilder.equal(root.get("name"),customReEntity.getName());
                list.add(p6);
            }
            if(customReEntity.getPhone() != null){
                //客户号码
                Predicate p7= criteriaBuilder.equal(root.get("phone"),customReEntity.getPhone());
                list.add(p7);
            }
            if(customReEntity.getCustomerSource() != null){
                //客户来源
                Predicate p8= criteriaBuilder.equal(root.get("customerSource"),customReEntity.getCustomerSource());
                list.add(p8);
            }
            return criteriaBuilder.and(list.toArray(new Predicate[0]));
        };
        Page<CustomerRegistration> lst = customerRegistrationRepository.findAll(specification, pageable);
        //查询来访记录信息
        for(CustomerRegistration customerRegistration : lst.getContent()){
            System.out.println("=====666========>"+customerRegistration.getId());
            customerRegistration.setRecord(customerRegistrationRepository.queryCustomerRecordList
                    (customerRegistration.getId()));
            customerRegistration.setLfNum(customerRegistration.getRecord().size());
        }
        return lst;
    }


    @Override
    public List<Integer> teamCustomerListE(CustomReEntity customReEntity) {
        List<Integer> re = new ArrayList<>();
        Integer j = 0;
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        /*Integer pageNumber = customReEntity.getPageNumber()-1;
        Integer pageSize = customReEntity.getPageSize();*/
        // 排序条件 默认最新
        Sort sort = new Sort(Sort.Direction.DESC, "id");
        if(customReEntity.getSort() != null){
            if (customReEntity.getSort().equals("DESC")) {
                sort = new Sort(Sort.Direction.DESC, customReEntity.getSortField());
            } else if(customReEntity.getSort().equals("ASC")){
                sort = new Sort(Sort.Direction.ASC, customReEntity.getSortField());
            }
        }
        //Pageable pageable = PageRequest.of(pageNumber,pageSize,sort);
        //动态查询条件
        Specification<CustomerRegistration> specification = (Specification<CustomerRegistration>)(root, query, criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            Predicate p0 = criteriaBuilder.notEqual(root.get("isSystem"),1);
            list.add(p0);
            if (customReEntity.getsTime() != null && customReEntity.geteTime() != null){
                Predicate p1= null;
                try {
                    p1 = criteriaBuilder.between(root.get("comeTime"),format.parse(customReEntity.getsTime()),format.parse(customReEntity.geteTime()));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                list.add(p1);
            }
            if (customReEntity.getCustomId() != null){
                //客户id查询
                Predicate p2 = criteriaBuilder.equal(root.get("id"),customReEntity.getCustomId());
                list.add(p2);
            }
            if (customReEntity.getLevel() != null){
                //客户等级查询
                Predicate p3= criteriaBuilder.equal(root.get("level"),customReEntity.getLevel());
                list.add(p3);
            }
            if (customReEntity.getCustomerType() != null){
                //客户状态
                Predicate p4= criteriaBuilder.equal(root.get("customerType"),customReEntity.getCustomerType());
                list.add(p4);
            }
            if (customReEntity.getReceptionId() != null){
                List ids = new ArrayList();
                String zy[] = customReEntity.getReceptionId().split(",");
                for (String id : zy){
                    ids.add(Integer.valueOf(id));
                }
                //置业顾问
                Path<Object> p5 = root.get("receptionId");//定义查询的字段
                CriteriaBuilder.In<Object> in = criteriaBuilder.in(p5);
                for (int i = 0; i <ids.size() ; i++) {
                    in.value(ids.get(i));//存入值
                }
                list.add(criteriaBuilder.and(criteriaBuilder.and(in)));//存入条件集合里
            }
            if(customReEntity.getName() != null){
                //客户姓名
                Predicate p6= criteriaBuilder.equal(root.get("name"),customReEntity.getName());
                list.add(p6);
            }
            if(customReEntity.getPhone() != null){
                //客户号码
                Predicate p7= criteriaBuilder.equal(root.get("phone"),customReEntity.getPhone());
                list.add(p7);
            }
            Predicate p8= criteriaBuilder.equal(root.get("visit"),1);
            list.add(p8);
            if(customReEntity.getCustomerSource() != null){
                //客户来源
                Predicate p9= criteriaBuilder.equal(root.get("customerSource"),customReEntity.getCustomerSource());
                list.add(p9);
            }
            return criteriaBuilder.and(list.toArray(new Predicate[0]));
        };
        List<CustomerRegistration> lst = customerRegistrationRepository.findAll(specification);
        if (lst != null){
            //查询来访记录信息
            for(CustomerRegistration customerRegistration : lst){
                if (customerRegistration.getCustomerType().equals("大定")){
                    j = j + 1;
                }
                if (customerRegistration.getCustomerType().equals("已交首付")){
                    j = j + 1;
                }
                if (customerRegistration.getCustomerType().equals("已全款")){
                    j = j + 1;
                }
            }
        }
        re.add(lst.size());
        re.add(j);
        return re;
    }

    @Override
    public JSONArray querySalesAnalysisOfTeamCustomers(CustomReEntity customReEntity) {
        List yxd = new ArrayList<>();
        //团队成交客户分析
        if(customReEntity.getIsCj().equals("1")){
            List types = new ArrayList();
            List ids = new ArrayList();
            //物业类型
            if (customReEntity.getPropertyType() == null && !customReEntity.getPropertyType().equals("不限")){
                String ts = customReEntity.getLevel();
                String s[] = ts.split(",");
                for (String b : s){
                    types.add(b);
                }
            }
            //团队信息需要传入销售员id 暂时时间问题没有考虑优化   后期·
            if (customReEntity.getReceptionId() != null && !customReEntity.getReceptionId().equals("全部")){
                String uid = customReEntity.getReceptionId();
                String usId[] = uid.split(",");
                for (String id : usId){
                    ids.add(id);
                }
            }
            //我的客户意向度分析
            if (customReEntity.getUsrIntentionality() != null && customReEntity.getUsrIntentionality() != ""){
                HashMap map = new HashMap();
                Integer a = 0,b = 0,c = 0,d = 0,e = 0,f = 0;   //等级数
                List<Object> z = null;
                if (ids.size() < 1 && types.size() < 1) {  //全部
                    z = customerRegistrationRepository.getUsrIntentionalityCj(customReEntity.getsTime(), customReEntity.geteTime());
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityCj(customReEntity.getsTime(), customReEntity.geteTime(),ids);
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityCjWRY(customReEntity.getsTime(), customReEntity.geteTime(),types);
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityCj(customReEntity.getsTime(), customReEntity.geteTime(),ids,types);
                }
                if (z.size() > 0){
                    for (int j = 0; j < z.size(); j++) {
                        Object[] objects = (Object[]) z.get(j);
                        if (objects[0].toString().equals("A")){
                            a++;
                        }else if (objects[0].toString().equals("B")){
                            b++;
                        }else if (objects[0].toString().equals("C")){
                            c++;
                        }else if (objects[0].toString().equals("D")){
                            d++;
                        }else if (objects[0].toString().equals("E")){
                            e++;
                        }else{
                            f++;
                        }
                    }
                }
                if (a > 0) {
                    map.put("A", a);
                }
                if (b > 0) {
                    map.put("B", b);
                }
                if (c > 0) {
                    map.put("C", c);
                }
                if (d > 0) {
                    map.put("D", d);
                }
                if (e > 0) {
                    map.put("E", e);
                }
                if (f > 0) {
                    map.put("未知", f);
                }
                yxd.add(map);
            }
            //团队客户购房目的
            if (customReEntity.getPurchasePurpose() != null && customReEntity.getPurchasePurpose() != ""){
                if (ids.size() < 1 && types.size() < 1) {  //全部
                    yxd.add(customerRegistrationRepository.getPurchasePurposeCAll(customReEntity.getsTime(), customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getPurchasePurposeRW(customReEntity.getsTime(), customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getPurchasePurposeWR(customReEntity.getsTime(), customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCustomerRegistrationRepositoryRWAll(customReEntity.getsTime(), customReEntity.geteTime(),ids,types));
                }
            }
            //团队客户所在区域分析
            if (customReEntity.getAreaName() != null && customReEntity.getAreaName() != ""){
                if (ids.size() < 1 && types.size() < 1) {  //全部
                    yxd.add(customerRegistrationRepository.getAreaNameCAll(customReEntity.getsTime(), customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameRW(customReEntity.getsTime(), customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameWR(customReEntity.getsTime(), customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameRWAll(customReEntity.getsTime(), customReEntity.geteTime(),ids,types));
                }
            }
            //团队客户到访次数
            if (customReEntity.getComeNum() != null && customReEntity.getComeNum() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getComeNumCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getComeNumRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getComeNumWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getComeNumRWAll(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的客户获知途径
            if (customReEntity.getAccessKnowledge() != null && customReEntity.getAccessKnowledge() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeRWAll(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的客户置业次数
            if (customReEntity.getHomeOwnership() != null && customReEntity.getHomeOwnership() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getHomeOwnershipCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnershipRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnershipWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnership(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的客户付款方式
            if (customReEntity.getPaymentType() != null && customReEntity.getPaymentType() != ""){
                if (ids.size() <= 1 && types.size() <= 1) { //全部
                    yxd.add(customerRegistrationRepository.getPaymentTypeCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() <= 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getPaymentTypeRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() <= 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getPaymentTypeWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnership(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的客户考虑因素
            if (customReEntity.getConsiderType() != null && customReEntity.getConsiderType() != ""){
                HashMap map = new HashMap();
                Integer qy = 0, dd = 0, xq = 0, hx = 0, yl = 0, jt = 0, zj = 0, pt = 0, pp = 0, gh = 0, tz = 0, qt = 0;
                List<Object> a = null;
                if (ids.size() < 1 && types.size() < 1) { //全部;
                    a = customerRegistrationRepository.getConsiderTypeCAll(customReEntity.getsTime(),customReEntity.geteTime());
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    a = customerRegistrationRepository.getConsiderTypeRW(customReEntity.getsTime(),customReEntity.geteTime(),types);
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    a = customerRegistrationRepository.getConsiderTypeWR(customReEntity.getsTime(),customReEntity.geteTime(),types);
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    a = customerRegistrationRepository.qy(customReEntity.getsTime(), customReEntity.geteTime(), ids, types);
                }
                if (a.size() >= 1) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        String cid = objects[0].toString();
                        if (objects[0].toString().contains("区域")) {
                            qy++;
                        }
                        if (objects[0].toString().contains("地段")) {
                            dd++;
                        }
                        if (objects[0].toString().contains("学区")) {
                            xq++;
                        }
                        if (objects[0].toString().contains("户型")) {
                            hx++;
                        }
                        if (objects[0].toString().contains("园林")) {
                            yl++;
                        }
                        if (objects[0].toString().contains("交通")) {
                            jt++;
                        }
                        if (objects[0].toString().contains("总价")) {
                            zj++;
                        }
                        if (objects[0].toString().contains("配套")) {
                            pt++;
                        }
                        if (objects[0].toString().contains("品牌")) {
                            pp++;
                        }
                        if (objects[0].toString().contains("规划")) {
                            gh++;
                        }
                        if (objects[0].toString().contains("投资")) {
                            tz++;
                        }
                        if (objects[0].toString().contains("其它")) {
                            qt++;
                        }
                    }
                    if (qy >= 1) {
                        map.put("区域", qy);
                    }
                    if (dd >= 1) {
                        map.put("地段", qy);
                    }
                    if (xq >= 1) {
                        map.put("学区", xq);
                    }
                    if (hx >= 1) {
                        map.put("户型", hx);
                    }
                    if (yl >= 1) {
                        map.put("园林", yl);
                    }
                    if (jt >= 1) {
                        map.put("交通", jt);
                    }
                    if (zj >= 1) {
                        map.put("总价", zj);
                    }
                    if (pt >= 1) {
                        map.put("配套", pt);
                    }
                    if (pp >= 1) {
                        map.put("品牌", pp);
                    }
                    if (gh >= 1) {
                        map.put("规划", gh);
                    }
                    if (tz >= 1) {
                        map.put("投资", tz);
                    }
                    if (qt >= 1) {
                        map.put("其它", qt);
                    }
                }
                yxd.add(map);
            }
            //我的客户家庭结构
            if (customReEntity.getFamilyStructure() != null && customReEntity.getFamilyStructure() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getFamilyStructureCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructureRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructureWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructure(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的客户主要职业
            if (customReEntity.getCustomerOccupation() != null && customReEntity.getCustomerOccupation() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getCustomerOccupationCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupationRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupationWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupation(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的成交客户购买户型
            if (customReEntity.getTypeOfClientele() != null && customReEntity.getTypeOfClientele() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getTypeOfClienteleCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getTypeOfClienteleRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getTypeOfClienteleWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getTypeOfClientele(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的客户购买总价
            if (customReEntity.getTotalClientPrice() != null && customReEntity.getTotalClientPrice() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getTotalClientPriceCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getTotalClientPriceRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getTotalClientPriceWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getTotalClientPrice(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //团队客户退房原因
            if (customReEntity.getCheckOutReason() != null && customReEntity.getCheckOutReason() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getCheckOutReasonCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getCheckOutReasonRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getCheckOutReasonWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCheckOutReason(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的客户销售产品分析
            if (customReEntity.getPromotingProducts() != null && customReEntity.getPromotingProducts() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getPromotingProductsCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getCheckOutReasonRW(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getCheckOutReasonWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCheckOutReason(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的销售数据统计
            /*if (customReEntity.getSalesStatistics() != null && customReEntity.getSalesStatistics() != ""){
                if (utp.equals("1")) {
                    yxd.add(customerRegistrationRepository.getSalesStatisticsN(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else{
                    yxd.add(customerRegistrationRepository.getSalesStatisticsT(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }*/
            //我的销售转化率分析
            if (customReEntity.getSalesConversionRate() != null && customReEntity.getSalesConversionRate() != ""){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getSalesConversionRateCAll(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getSalesConversionRateT(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getSalesConversionRateN(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getSalesConversionRateT(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //我的成交客户销售状态
            /*if (customReEntity.getCustomerSalesStatus() != null && customReEntity.getCustomerSalesStatus() != ""){
                if (utp.equals("1")) {
                    yxd.add(customerRegistrationRepository.getCustomerSalesStatusN(customReEntity.getsTime(),customReEntity.geteTime(),types));
                    //按两次数据获取 其中***
                    yxd.add(customerRegistrationRepository.getAmongN(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else{
                    yxd.add(customerRegistrationRepository.getCustomerSalesStatusT(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                    //按两次数据获取 其中***
                    yxd.add(customerRegistrationRepository.getAmongT(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }*/

            //客户来源
            if (customReEntity.getCustomerSource() !=null){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getCustomerSourceSE(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSource(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSourceWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSource(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //拒绝原因
            if (customReEntity.getRefuseReason() !=null){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getRefuseReasonSE(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReason(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReasonWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReason(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //是否看过样板房
            if (customReEntity.getModelHouses() !=null){
                if (ids.size() < 1 && types.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getModelHousesSE(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (ids.size() >= 1 && types.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getModelHouses(customReEntity.getsTime(),customReEntity.geteTime(),ids));
                }else if (ids.size() < 1 && types.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getModelHousesWR(customReEntity.getsTime(),customReEntity.geteTime(),types));
                }else if (ids.size() >= 1 && types.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getModelHouses(customReEntity.getsTime(),customReEntity.geteTime(),ids,types));
                }
            }
            //佣金待定
        }else if (customReEntity.getIsCj().equals("0")){
            //我的未成交客户分析
            List typesE = new ArrayList();
            List idsE = new ArrayList();
            if (customReEntity.getPropertyType() != null && !customReEntity.getPropertyType().equals("不限")){
                String ts = customReEntity.getLevel();
                String s[] = ts.split(",");
                for (String b : s){
                    typesE.add(b);
                }
            }
            //团队信息需要传入销售员id 暂时时间问题没有考虑优化   后期·
            if (customReEntity.getReceptionId() != null && !customReEntity.getReceptionId().equals("全部")){
                String uid = customReEntity.getReceptionId();
                String usId[] = uid.split(",");
                for (String id : usId){
                    idsE.add(id);
                }
            }
            //团队客户意向度分析  ====> 客户等级
            if (customReEntity.getUsrIntentionality() != null && customReEntity.getUsrIntentionality() != ""){
                HashMap map = new HashMap();
                Integer a = 0,b = 0,c = 0,d = 0,e = 0,f = 0;   //等级数
                List<Object> z = null;
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    //20200116 修改等级
                    z = customerRegistrationRepository.getUsrIntentionalityWCj(customReEntity.getsTime(),customReEntity.geteTime());
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityWCj(customReEntity.getsTime(),customReEntity.geteTime(),idsE);
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityWCjWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE);
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityWCj(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE);
                }
                if (z.size() > 0){
                    for (int j = 0; j < z.size(); j++) {
                        Object[] objects = (Object[]) z.get(j);
                        if (objects[0].toString().equals("A")){
                            a++;
                        }else if (objects[0].toString().equals("B")){
                            b++;
                        }else if (objects[0].toString().equals("C")){
                            c++;
                        }else if (objects[0].toString().equals("D")){
                            d++;
                        }else if (objects[0].toString().equals("E")){
                            e++;
                        }else{
                            f++;
                        }
                    }
                }
                if (a > 0) {
                    map.put("A", a);
                }
                if (b > 0) {
                    map.put("B", b);
                }
                if (c > 0) {
                    map.put("C", c);
                }
                if (d > 0) {
                    map.put("D", d);
                }
                if (e > 0) {
                    map.put("E", e);
                }
                if (f > 0) {
                    map.put("未知", f);
                }
                yxd.add(map);
            }
            //购房目的
            if (customReEntity.getPurchasePurpose() != null && customReEntity.getPurchasePurpose() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getPurchasePurposeSE(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getPurchasePurposeW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getPurchasePurposeWS(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getPurchasePurposeW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //我的客户所在区域分析
            if (customReEntity.getAreaName() != null && customReEntity.getAreaName() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getAreaNameZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //我的客户到访次数
            if (customReEntity.getComeNum() != null && customReEntity.getComeNum() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getComeNumZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getComeNumW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getComeNumWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getComeNumW(customReEntity.getsTime(), customReEntity.geteTime(),idsE,typesE));
                }
            }
            //我的客户获知途径
            if (customReEntity.getAccessKnowledge() != null && customReEntity.getAccessKnowledge() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //我的客户面积需求
            if (customReEntity.getAreaNeed() != null && customReEntity.getAreaNeed() != ""){
                HashMap map = new HashMap();
                Integer lsf = 0,bsf = 0,ybf = 0,ybef = 0,ybsf = 0,yblf = 0,ybjf = 0,ebwf = 0,sbf = 0,ssbf = 0,wbf = 0, wbysf = 0;
                List<Object> a = null;
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    a = customerRegistrationRepository.getAreaNeedWZ(customReEntity.getsTime(), customReEntity.geteTime());
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    a = customerRegistrationRepository.getAreaNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsE);
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getAreaNeedWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    a = customerRegistrationRepository.getAreaNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsE, typesE);
                }
                if (a.size() >= 1) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("60方以下")) {
                            lsf++;
                        }
                        if (objects[0].toString().contains("61-89方")) {
                            bsf++;
                        }
                        if (objects[0].toString().contains("90-100方")) {
                            ybf++;
                        }
                        if (objects[0].toString().contains("100-120方")) {
                            ybef++;
                        }
                        if (objects[0].toString().contains("121-140方")) {
                            ybsf++;
                        }
                        if (objects[0].toString().contains("140-160方")) {
                            yblf++;
                        }
                        if (objects[0].toString().contains("161-195方")) {
                            ybjf++;
                        }
                        if (objects[0].toString().contains("196-250方")) {
                            ebwf++;
                        }
                        if (objects[0].toString().contains("251-300方")) {
                            sbf++;
                        }
                        if (objects[0].toString().contains("301-400方")) {
                            ssbf++;
                        }
                        if (objects[0].toString().contains("401-500方")) {
                            wbf++;
                        }
                        if (objects[0].toString().contains("500以上")) {
                            wbysf++;
                        }
                    }
                }
                if (lsf >= 1) {
                    map.put("60方以下", lsf);
                }
                if (bsf >= 1) {
                    map.put("61-89方", bsf);
                }
                if (ybf >= 1) {
                    map.put("90-100方", ybf);
                }
                if (ybef >= 1) {
                    map.put("100-120方", ybef);
                }
                if (ybsf >= 1) {
                    map.put("121-140方", ybsf);
                }
                if (yblf >= 1) {
                    map.put("140-160方", yblf);
                }
                if (ybjf >= 1) {
                    map.put("161-195方", ybjf);
                }
                if (ebwf >= 1) {
                    map.put("196-250方", ebwf);
                }
                if (sbf >= 1) {
                    map.put("251-300方", sbf);
                }
                if (ssbf >= 1) {
                    map.put("301-400方", ssbf);
                }
                if (wbf >= 1) {
                    map.put("401-500方", wbf);
                }
                if (wbysf >= 1) {
                    map.put("500以上", wbysf);
                }
                yxd.add(map);
            }
            //我的客户意向户型
            /*if (customReEntity.getIntentionalHouseholdType() != null && customReEntity.getIntentionalHouseholdType() != ""){
                if (idsE.size() <= 1 && typesE.size() <= 1) { //全部
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() <= 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() <= 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }*/
            //我的客户年龄分析
            if (customReEntity.getAge() != null){
                //20191206
                HashMap hs = new HashMap();
                Integer qt = 0,es = 0,ss = 0,sw = 0,wl = 0;
                List<Object> nld = null;
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    nld = customerRegistrationRepository.getAgeZ(customReEntity.getsTime(),customReEntity.geteTime());
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    nld = customerRegistrationRepository.getAgeW(customReEntity.getsTime(), customReEntity.geteTime(), idsE);
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    nld = customerRegistrationRepository.getAgeT(customReEntity.getsTime(),customReEntity.geteTime(),typesE);
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    nld = customerRegistrationRepository.getAgeW(customReEntity.getsTime(), customReEntity.geteTime(), idsE, typesE);
                }
                if (nld.size() >= 1){
                    for (int k =0;k<nld.size();k++){
                        Object[] objects = (Object[]) nld.get(k);
                        if (Integer.valueOf(objects[0].toString()) >= 1 && Integer.valueOf(objects[0].toString()) < 20) {
                            qt++; //其它
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 20 && Integer.valueOf(objects[0].toString()) < 30) {
                            es++; //20-30
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 30 && Integer.valueOf(objects[0].toString()) < 40) {
                            ss++; //30-40
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 40 && Integer.valueOf(objects[0].toString()) < 50) {
                            sw++; //40-50
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 50 && Integer.valueOf(objects[0].toString()) < 60) {
                            wl++; //50-60
                        }
                        if (Integer.valueOf(objects[0].toString()) > 60) {
                            qt++; //其它
                        }
                    }
                    if (qt >= 1) {
                        hs.put("其它", qt);
                    }
                    if (es >= 1) {
                        hs.put("20-30岁", es);
                    }
                    if (ss >= 1) {
                        hs.put("30-40岁", ss);
                    }
                    if (sw >= 1) {
                        hs.put("40-50岁", sw);
                    }
                    if (wl >= 1) {
                        hs.put("50-60岁", wl);
                    }
                    yxd.add(hs);
                }
            }
            //我的客户总价需求
            if (customReEntity.getTotalNeed() != null && customReEntity.getTotalNeed() != ""){
                HashMap map = new HashMap();
                Integer ybw = 0,ybww = 0,ebw = 0,sbw = 0,ssbw = 0,wbw = 0,qbw = 0,qbwys = 0;
                List<Object> a = null;
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    a = customerRegistrationRepository.getAreaNeedDxS(customReEntity.getsTime(), customReEntity.geteTime());
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    a = customerRegistrationRepository.getTotalNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsE);
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    a = customerRegistrationRepository.getAreaNeedDxWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE);
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    a = customerRegistrationRepository.getTotalNeedDxW(customReEntity.getsTime(), customReEntity.geteTime(), idsE, typesE);
                }
                if (a.size() >= 1){
                    for (int j = 0;j < a.size();j ++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("100万以下")) {
                            ybw++;
                        }
                        if (objects[0].toString().contains("100-150万")) {
                            ybww++;
                        }
                        if (objects[0].toString().contains("151-200万")) {
                            ebw++;
                        }
                        if (objects[0].toString().contains("200-300万")) {
                            sbw++;
                        }
                        if (objects[0].toString().contains("300-400万")) {
                            ssbw++;
                        }
                        if (objects[0].toString().contains("400-500万")) {
                            wbw++;
                        }
                        if (objects[0].toString().contains("500-700万")) {
                            qbw++;
                        }
                        if (objects[0].toString().contains("700万以上")) {
                            qbwys++;
                        }
                    }
                    if (ybw >= 1){
                        map.put("100万以下",ybw);
                    }
                    if (ybww >= 1){
                        map.put("100-150万",ybww);
                    }
                    if (ebw >= 1){
                        map.put("151-200万",ebw);
                    }
                    if (sbw >= 1){
                        map.put("200-300万",sbw);
                    }
                    if (ssbw >= 1){
                        map.put("300-400万",ssbw);
                    }
                    if (wbw >= 1){
                        map.put("400-500万",wbw);
                    }
                    if (qbw >= 1){
                        map.put("500-700万",qbw);
                    }
                    if (qbwys >= 1){
                        map.put("700万以上",qbwys);
                    }
                }
                yxd.add(map);
            }
            //我的客户付款方式
            if (customReEntity.getPaymentType() != null && customReEntity.getPaymentType() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getPaymentTypeZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getPaymentTypeW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getPaymentTypeT(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getPaymentTypeW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //我的客户价格接受度
            if (customReEntity.getPriceAcceptance() != null && customReEntity.getPriceAcceptance() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceT(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //我的客户考虑因素
            if (customReEntity.getConsiderType() != null && customReEntity.getConsiderType() != ""){
                HashMap map = new HashMap();
                Integer qy = 0, dd = 0, xq = 0, hx = 0, yl = 0, jt = 0, zj = 0, pt = 0, pp = 0, gh = 0, tz = 0, qt = 0;
                List<Object> a = null;
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    a = customerRegistrationRepository.qyZ(customReEntity.getsTime(),customReEntity.geteTime());
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    a = customerRegistrationRepository.qyW(customReEntity.getsTime(),customReEntity.geteTime(),idsE);
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    a = customerRegistrationRepository.qyWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE);
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    a = customerRegistrationRepository.qyW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE);
                }
                if (a.size() >= 1) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        String cid = objects[0].toString();
                        if (objects[0].toString().contains("区域")) {
                            qy++;
                        }
                        if (objects[0].toString().contains("地段")) {
                            dd++;
                        }
                        if (objects[0].toString().contains("学区")) {
                            xq++;
                        }
                        if (objects[0].toString().contains("户型")) {
                            hx++;
                        }
                        if (objects[0].toString().contains("园林")) {
                            yl++;
                        }
                        if (objects[0].toString().contains("交通")) {
                            jt++;
                        }
                        if (objects[0].toString().contains("总价")) {
                            zj++;
                        }
                        if (objects[0].toString().contains("配套")) {
                            pt++;
                        }
                        if (objects[0].toString().contains("品牌")) {
                            pp++;
                        }
                        if (objects[0].toString().contains("规划")) {
                            gh++;
                        }
                        if (objects[0].toString().contains("投资")) {
                            tz++;
                        }
                        if (objects[0].toString().contains("其它")) {
                            qt++;
                        }
                    }
                    if (qy >= 1) {
                        map.put("区域", qy);
                    }
                    if (dd >= 1) {
                        map.put("地段", qy);
                    }
                    if (xq >= 1) {
                        map.put("学区", xq);
                    }
                    if (hx >= 1) {
                        map.put("户型", hx);
                    }
                    if (yl >= 1) {
                        map.put("园林", yl);
                    }
                    if (jt >= 1) {
                        map.put("交通", jt);
                    }
                    if (zj >= 1) {
                        map.put("总价", zj);
                    }
                    if (pt >= 1) {
                        map.put("配套", pt);
                    }
                    if (pp >= 1) {
                        map.put("品牌", pp);
                    }
                    if (gh >= 1) {
                        map.put("规划", gh);
                    }
                    if (tz >= 1) {
                        map.put("投资", tz);
                    }
                    if (qt >= 1) {
                        map.put("其它", qt);
                    }
                }
                yxd.add(map);
            }
            //我的客户户型需求
            if (customReEntity.getHouseTypeNeed() != null && customReEntity.getHouseTypeNeed() != ""){
                HashMap map = new HashMap();
                Integer yf = 0,ef = 0,sfyw = 0,sflw = 0,ssfyw =0,ssflw =0,wf = 0,lfys = 0;
                List<Object> a = null;
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    a = customerRegistrationRepository.getHouseTypeNeedDxZ(customReEntity.getsTime(),customReEntity.geteTime());
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    a = customerRegistrationRepository.getHouseTypeNeedDxW(customReEntity.getsTime(),customReEntity.geteTime(),idsE);
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    a = customerRegistrationRepository.getHouseTypeNeedDxWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE);
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    a = customerRegistrationRepository.getHouseTypeNeedDxW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE);
                }
                if (a.size() >= 1){
                    for (int j = 0;j < a.size();j ++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("一房")) {
                            yf++;
                        }
                        if (objects[0].toString().contains("二房")) {
                            ef++;
                        }
                        if (objects[0].toString().contains("三房一卫")) {
                            sfyw++;
                        }
                        if (objects[0].toString().contains("三房两卫")) {
                            sflw++;
                        }
                        if (objects[0].toString().contains("四房一卫")) {
                            ssfyw++;
                        }
                        if (objects[0].toString().contains("四房两卫")) {
                            ssflw++;
                        }
                        if (objects[0].toString().contains("五房")) {
                            wf++;
                        }
                        if (objects[0].toString().contains("六房及以上")) {
                            lfys++;
                        }
                    }
                    if (yf >= 1){
                        map.put("一房",yf);
                    }
                    if (ef >= 1){
                        map.put("二房",ef);
                    }
                    if (sfyw >= 1){
                        map.put("三房一卫",sfyw);
                    }
                    if (sflw >= 1){
                        map.put("三房两卫",sflw);
                    }
                    if (ssfyw >= 1){
                        map.put("四房一卫",ssfyw);
                    }
                    if (ssflw >= 1){
                        map.put("四房两卫",ssflw);
                    }
                    if (wf >= 1){
                        map.put("五房",wf);
                    }
                    if (lfys >= 1){
                        map.put("六房及以上",lfys);
                    }
                }
                yxd.add(map);
            }
            //我的客户家庭结构
            if (customReEntity.getFamilyStructure() != null && customReEntity.getFamilyStructure() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getFamilyStructureZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructureW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructureWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructureW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //我的客户置业次数
            if (customReEntity.getHomeOwnership() != null && customReEntity.getHomeOwnership() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getHomeOwnershipZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnershipW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnershipWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnershipW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //我的客户主要职业
            if (customReEntity.getCustomerOccupation() != null && customReEntity.getCustomerOccupation() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getCustomerOccupationZ(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupationW(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupationN(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupationW(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //客户来源
            if (customReEntity.getCustomerSource() !=null && customReEntity.getCustomerSource() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getCustomerSourceWSE(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSourceM(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSourceWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSourceM(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //拒绝原因
            if (customReEntity.getRefuseReason() !=null && customReEntity.getRefuseReason() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getRefuseReasonWSE(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReasonM(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReasonWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReasonM(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
            //是否看过样板房
            if (customReEntity.getModelHouses() !=null && customReEntity.getModelHouses() != ""){
                if (idsE.size() < 1 && typesE.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getModelHousesWSE(customReEntity.getsTime(),customReEntity.geteTime()));
                }else if (idsE.size() >= 1 && typesE.size() < 1){ //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getModelHousesM(customReEntity.getsTime(),customReEntity.geteTime(),idsE));
                }else if (idsE.size() < 1 && typesE.size() >= 1){ //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getModelHousesWRY(customReEntity.getsTime(),customReEntity.geteTime(),typesE));
                }else if (idsE.size() >= 1 && typesE.size() >= 1){ //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getModelHousesM(customReEntity.getsTime(),customReEntity.geteTime(),idsE,typesE));
                }
            }
        }else{
            //成交和未成交客户信息分析 C   20191206
            List typesAll = new ArrayList();
            List idsAll = new ArrayList();
            if (customReEntity.getPropertyType() != null && !customReEntity.getPropertyType().equals("不限")){
                String ts = customReEntity.getPropertyType();
                String s[] = ts.split(",");
                for (String b : s){
                    typesAll.add(b);
                }
            }
            if (customReEntity.getReceptionId() != null && !customReEntity.getReceptionId().equals("全部")){
                String uid = customReEntity.getReceptionId();
                String usId[] = uid.split(",");
                for (String id : usId){
                    idsAll.add(id);
                }
            }
            //我的客户意向度分析
            if (customReEntity.getUsrIntentionality() != null && customReEntity.getUsrIntentionality() != ""){
                HashMap map = new HashMap();
                Integer a = 0,b = 0,c = 0,d = 0,e = 0,f = 0;   //等级数
                List<Object> z = null;
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    z = customerRegistrationRepository.getUsrIntentionalityAll(customReEntity.getsTime(), customReEntity.geteTime());
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll);
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    z = customerRegistrationRepository.getUsrIntentionalityAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll, typesAll);
                }
                if (z.size() > 0){
                    for (int j = 0; j < z.size(); j++) {
                        Object[] objects = (Object[]) z.get(j);
                        if (objects[0].toString().equals("A")){
                            a++;
                        }else if (objects[0].toString().equals("B")){
                            b++;
                        }else if (objects[0].toString().equals("C")){
                            c++;
                        }else if (objects[0].toString().equals("D")){
                            d++;
                        }else if (objects[0].toString().equals("E")){
                            e++;
                        }else{
                            f++;
                        }
                    }
                }
                if (a > 0) {
                    map.put("A", a);
                }
                if (b > 0) {
                    map.put("B", b);
                }
                if (c > 0) {
                    map.put("C", c);
                }
                if (d > 0) {
                    map.put("D", d);
                }
                if (e > 0) {
                    map.put("E", e);
                }
                if (f > 0) {
                    map.put("未知", f);
                }
                yxd.add(map);
            }
            //购房目的
            if (customReEntity.getPurchasePurpose() != null && customReEntity.getPurchasePurpose() != "") {
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getPurchasePurposeAll(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getPurchasePurposeAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getPurchasePurposeWYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getPurchasePurposeAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll, typesAll));
                }
            }
            //所在区域
            if (customReEntity.getAreaName() != null){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getAreaNameAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getAreaNameAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //到访次数
            if (customReEntity.getComeNum() != null){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getComeNumAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getComeNumAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getComeNumWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getComeNumAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //获知途径
            if (customReEntity.getAccessKnowledge() != null){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getComeNumWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getAccessKnowledgeAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //面积需求
            if (customReEntity.getAreaNeed() != null){
                List<Object> a = null;
                HashMap map = new HashMap();
                Integer lsf = 0, bsf = 0, ybf = 0, ybef = 0, ybsf = 0, yblf = 0, ybjf = 0, ebwf = 0, sbf = 0, ssbf = 0, wbf = 0, wbysf = 0;
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    a = customerRegistrationRepository.getAreaNeedDxAllZ(customReEntity.getsTime(), customReEntity.geteTime());
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    a = customerRegistrationRepository.getAreaNeedDxAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    a = customerRegistrationRepository.getAreaNeedDxWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll);
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    a = customerRegistrationRepository.getAreaNeedDxAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll);
                }
                if (a.size() >= 1) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("60方以下")) {
                            lsf++;
                        }
                        if (objects[0].toString().contains("61-89方")) {
                            bsf++;
                        }
                        if (objects[0].toString().contains("90-100方")) {
                            ybf++;
                        }
                        if (objects[0].toString().contains("100-120方")) {
                            ybef++;
                        }
                        if (objects[0].toString().contains("121-140方")) {
                            ybsf++;
                        }
                        if (objects[0].toString().contains("140-160方")) {
                            yblf++;
                        }
                        if (objects[0].toString().contains("161-195方")) {
                            ybjf++;
                        }
                        if (objects[0].toString().contains("196-250方")) {
                            ebwf++;
                        }
                        if (objects[0].toString().contains("251-300方")) {
                            sbf++;
                        }
                        if (objects[0].toString().contains("301-400方")) {
                            ssbf++;
                        }
                        if (objects[0].toString().contains("401-500方")) {
                            wbf++;
                        }
                        if (objects[0].toString().contains("500以上")) {
                            wbysf++;
                        }
                    }
                    if (lsf >= 1) {
                        map.put("60方以下", lsf);
                    }
                    if (bsf >= 1) {
                        map.put("61-89方", bsf);
                    }
                    if (ybf >= 1) {
                        map.put("90-100方", ybf);
                    }
                    if (ybef >= 1) {
                        map.put("100-120方", ybef);
                    }
                    if (ybsf >= 1) {
                        map.put("121-140方", ybsf);
                    }
                    if (yblf >= 1) {
                        map.put("140-160方", yblf);
                    }
                    if (ybjf >= 1) {
                        map.put("161-195方", ybjf);
                    }
                    if (ebwf >= 1) {
                        map.put("196-250方", ebwf);
                    }
                    if (sbf >= 1) {
                        map.put("251-300方", sbf);
                    }
                    if (ssbf >= 1) {
                        map.put("301-400方", ssbf);
                    }
                    if (wbf >= 1) {
                        map.put("401-500方", wbf);
                    }
                    if (wbysf >= 1) {
                        map.put("500以上", wbysf);
                    }
                    yxd.add(map);
                }
            }
            //年龄段
            if (customReEntity.getAge() != null){
                //20191206
                HashMap hs = new HashMap();
                Integer qt = 0,es = 0,ss = 0,sw = 0,wl = 0;
                List<Object> nld = null;
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    nld = customerRegistrationRepository.getAgeAllZ(customReEntity.getsTime(), customReEntity.geteTime());
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    nld = customerRegistrationRepository.getAgeAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    nld = customerRegistrationRepository.getAgeWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll);
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    nld = customerRegistrationRepository.getAgeAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll);
                }
                if (nld.size() >= 1){
                    for (int k =0;k<nld.size();k++){
                        Object[] objects = (Object[])nld.get(k);
                        if (Integer.valueOf(objects[0].toString()) >= 1 && Integer.valueOf(objects[0].toString()) < 20) {
                            qt++; //其它
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 20 && Integer.valueOf(objects[0].toString()) < 30) {
                            es++; //20-30
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 30 && Integer.valueOf(objects[0].toString()) < 40) {
                            ss++; //30-40
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 40 && Integer.valueOf(objects[0].toString()) < 50) {
                            sw++; //40-50
                        }
                        if (Integer.valueOf(objects[0].toString()) >= 50 && Integer.valueOf(objects[0].toString()) < 60) {
                            wl++; //50-60
                        }
                        if (Integer.valueOf(objects[0].toString()) > 60) {
                            qt++; //其它
                        }
                    }
                    if (qt >= 1) {
                        hs.put("其它", qt);
                    }
                    if (es >= 1) {
                        hs.put("20-30岁", es);
                    }
                    if (ss >= 1) {
                        hs.put("30-40岁", ss);
                    }
                    if (sw >= 1) {
                        hs.put("40-50岁", sw);
                    }
                    if (wl >= 1) {
                        hs.put("50-60岁", wl);
                    }
                    yxd.add(hs);
                }
            }
            //置业次数
            if (customReEntity.getHomeOwnership() != null){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getHomeOwnershipAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnershipAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnershipWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getHomeOwnershipAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //总价需求
            if (customReEntity.getTotalNeed() != null && customReEntity.getTotalNeed() != "") {
                //20191206
                HashMap map = new HashMap();
                List<Object> a = null;
                Integer ybw = 0, ybww = 0, ebw = 0, sbw = 0, ssbw = 0, wbw = 0, qbw = 0, qbwys = 0;
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    a = customerRegistrationRepository.getTotalNeedDxAllZ(customReEntity.getsTime(), customReEntity.geteTime());
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    a = customerRegistrationRepository.getTotalNeedDxAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    a = customerRegistrationRepository.getTotalNeedDxWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll);
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    a = customerRegistrationRepository.getTotalNeedDxAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll,typesAll);
                }
                if (a.size() >= 1) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("100万以下")) {
                            ybw++;
                        }
                        if (objects[0].toString().contains("100-150万")) {
                            ybww++;
                        }
                        if (objects[0].toString().contains("151-200万")) {
                            ebw++;
                        }
                        if (objects[0].toString().contains("200-300万")) {
                            sbw++;
                        }
                        if (objects[0].toString().contains("300-400万")) {
                            ssbw++;
                        }
                        if (objects[0].toString().contains("400-500万")) {
                            wbw++;
                        }
                        if (objects[0].toString().contains("500-700万")) {
                            qbw++;
                        }
                        if (objects[0].toString().contains("700万以上")) {
                            qbwys++;
                        }
                    }
                    if (ybw >= 1) {
                        map.put("100万以下", ybw);
                    }
                    if (ybww >= 1) {
                        map.put("100-150万", ybww);
                    }
                    if (ebw >= 1) {
                        map.put("151-200万", ebw);
                    }
                    if (sbw >= 1) {
                        map.put("200-300万", sbw);
                    }
                    if (ssbw >= 1) {
                        map.put("300-400万", ssbw);
                    }
                    if (wbw >= 1) {
                        map.put("400-500万", wbw);
                    }
                    if (qbw >= 1) {
                        map.put("500-700万", qbw);
                    }
                    if (qbwys >= 1) {
                        map.put("700万以上", qbwys);
                    }
                    yxd.add(map);
                }
                yxd.add(map);
            }
            //价格接受度
            if (customReEntity.getPriceAcceptance() != null && customReEntity.getPriceAcceptance() != ""){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getPriceAcceptanceAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //考虑因素
            if (customReEntity.getConsiderType() != null && customReEntity.getConsiderType() != ""){
                HashMap map = new HashMap();
                Integer qy = 0, dd = 0, xq = 0, hx = 0, yl = 0, jt = 0, zj = 0, pt = 0, pp = 0, gh = 0, tz = 0, qt = 0;
                List<Object> a = null;
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    a = customerRegistrationRepository.qyAllZ(customReEntity.getsTime(), customReEntity.geteTime());
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    a = customerRegistrationRepository.qyAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    a = customerRegistrationRepository.qyWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll);
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    a = customerRegistrationRepository.qyAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll);
                }
                if (a.size() >= 1) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        String cid = objects[0].toString();
                        if (objects[0].toString().contains("区域")) {
                            qy++;
                        }
                        if (objects[0].toString().contains("地段")) {
                            dd++;
                        }
                        if (objects[0].toString().contains("学区")) {
                            xq++;
                        }
                        if (objects[0].toString().contains("户型")) {
                            hx++;
                        }
                        if (objects[0].toString().contains("园林")) {
                            yl++;
                        }
                        if (objects[0].toString().contains("交通")) {
                            jt++;
                        }
                        if (objects[0].toString().contains("总价")) {
                            zj++;
                        }
                        if (objects[0].toString().contains("配套")) {
                            pt++;
                        }
                        if (objects[0].toString().contains("品牌")) {
                            pp++;
                        }
                        if (objects[0].toString().contains("规划")) {
                            gh++;
                        }
                        if (objects[0].toString().contains("投资")) {
                            tz++;
                        }
                        if (objects[0].toString().contains("其它")) {
                            qt++;
                        }
                    }
                    if (qy >= 1) {
                        map.put("区域", qy);
                    }
                    if (dd >= 1) {
                        map.put("地段", qy);
                    }
                    if (xq >= 1) {
                        map.put("学区", xq);
                    }
                    if (hx >= 1) {
                        map.put("户型", hx);
                    }
                    if (yl >= 1) {
                        map.put("园林", yl);
                    }
                    if (jt >= 1) {
                        map.put("交通", jt);
                    }
                    if (zj >= 1) {
                        map.put("总价", zj);
                    }
                    if (pt >= 1) {
                        map.put("配套", pt);
                    }
                    if (pp >= 1) {
                        map.put("品牌", pp);
                    }
                    if (gh >= 1) {
                        map.put("规划", gh);
                    }
                    if (tz >= 1) {
                        map.put("投资", tz);
                    }
                    if (qt >= 1) {
                        map.put("其它", qt);
                    }
                }
                yxd.add(map);
            }
            //户型需求
            if (customReEntity.getHouseTypeNeed() != null && customReEntity.getHouseTypeNeed() != ""){
                HashMap map = new HashMap();
                Integer yf = 0,ef = 0,sfyw = 0,sflw = 0,ssfyw =0,ssflw =0,wf = 0,lfys = 0;
                List<Object> a = null;
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    a = customerRegistrationRepository.getHouseTypeNeedDxAllZ(customReEntity.getsTime(), customReEntity.geteTime());
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    a = customerRegistrationRepository.getHouseTypeNeedDxAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll);
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    a = customerRegistrationRepository.getHouseTypeNeedDxWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll);
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    a = customerRegistrationRepository.getHouseTypeNeedDxAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll);
                }
                if (a.size() >= 1) {
                    for (int j = 0; j < a.size(); j++) {
                        Object[] objects = (Object[]) a.get(j);
                        if (objects[0].toString().contains("一房")) {
                            yf++;
                        }
                        if (objects[0].toString().contains("二房")) {
                            ef++;
                        }
                        if (objects[0].toString().contains("三房一卫")) {
                            sfyw++;
                        }
                        if (objects[0].toString().contains("三房两卫")) {
                            sflw++;
                        }
                        if (objects[0].toString().contains("四房一卫")) {
                            ssfyw++;
                        }
                        if (objects[0].toString().contains("四房两卫")) {
                            ssflw++;
                        }
                        if (objects[0].toString().contains("五房")) {
                            wf++;
                        }
                        if (objects[0].toString().contains("六房及以上")) {
                            lfys++;
                        }
                    }
                    if (yf >= 1) {
                        map.put("一房", yf);
                    }
                    if (ef >= 1) {
                        map.put("二房", ef);
                    }
                    if (sfyw >= 1) {
                        map.put("三房一卫", sfyw);
                    }
                    if (sflw >= 1) {
                        map.put("三房两卫", sflw);
                    }
                    if (ssfyw >= 1) {
                        map.put("四房一卫", ssfyw);
                    }
                    if (ssflw >= 1) {
                        map.put("四房两卫", ssflw);
                    }
                    if (wf >= 1) {
                        map.put("五房", wf);
                    }
                    if (lfys >= 1) {
                        map.put("六房及以上", lfys);
                    }
                    yxd.add(map);
                }
            }
            //家庭结构
            if (customReEntity.getFamilyStructure() != null && customReEntity.getFamilyStructure() != ""){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getFamilyStructureAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructureAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructureWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getFamilyStructureAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //客户职业
            if (customReEntity.getCustomerOccupation() != null && customReEntity.getCustomerOccupation() != ""){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getCustomerOccupationAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupationAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupationWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCustomerOccupationAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //客户来源
            if (customReEntity.getCustomerSource() !=null){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getCustomerSourceAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSourceAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSourceWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getCustomerSourceAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //拒绝原因
            if (customReEntity.getRefuseReason() !=null){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getRefuseReasonAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReasonAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReasonWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getRefuseReasonAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
            //是否看过样板房
            if (customReEntity.getModelHouses() !=null){
                if (idsAll.size() < 1 && typesAll.size() < 1) { //全部
                    yxd.add(customerRegistrationRepository.getModelHousesAllZ(customReEntity.getsTime(), customReEntity.geteTime()));
                } else if (idsAll.size() >= 1 && typesAll.size() < 1) { //选择人员没选物业类型
                    yxd.add(customerRegistrationRepository.getModelHousesAll(customReEntity.getsTime(), customReEntity.geteTime(), idsAll));
                } else if (idsAll.size() < 1 && typesAll.size() >= 1) { //没选择人员选择物业类型
                    yxd.add(customerRegistrationRepository.getModelHousesWRYAll(customReEntity.getsTime(), customReEntity.geteTime(), typesAll));
                } else if (idsAll.size() >= 1 && typesAll.size() >= 1) { //选择人员和物业类型
                    yxd.add(customerRegistrationRepository.getModelHousesAll(customReEntity.getsTime(),customReEntity.geteTime(),idsAll,typesAll));
                }
            }
        }
        JSONArray jsonArray=new JSONArray(yxd);
        return jsonArray;
    }

    @Override
    public JSONArray queryMyRank(CustomReEntity customReEntity) {
        //我的成交客户
        List yjList = new ArrayList<>();
        List types = new ArrayList();
        List ids = new ArrayList();
        //默认A类型客户
        if (customReEntity.getLevel() == null || customReEntity.getLevel() == ""){
            types.add("A");
        }else{
            String ts = customReEntity.getLevel();
            String s[] = ts.split(",");
            for (String b : s){
                types.add(b);
            }
        }
            List l = customerRegistrationRepository.getCjCustomer(customReEntity.getUserId(),customReEntity.getsTime(), customReEntity.geteTime(),types);
            yjList.add(l);
        JSONArray jsonArray=new JSONArray(yjList);
        return jsonArray;
    }


    public JSONArray queryTeamRank(CustomReEntity customReEntity) {
        //我的成交客户
        List yjList = new ArrayList<>();
        List types = new ArrayList();
        List ids = new ArrayList();
        //默认A类型客户
        if (customReEntity.getLevel() == null || customReEntity.getLevel() == ""){
            types.add("A");
        }else{
            String ts = customReEntity.getLevel();
            String s[] = ts.split(",");
            for (String b : s){
                types.add(b);
            }
        }
        List<Object> ul = customerRegistrationRepository.getUserList();  //获取销售员信息
        if (ul.size() >  0){
            for (int j = 0;j < ul.size();j ++){
                Object[] objects = (Object[]) ul.get(j);
                String cid = objects[0].toString();
                List l = customerRegistrationRepository.getCjCustomer(cid.toString(),customReEntity.getsTime(), customReEntity.geteTime(),types);
                yjList.add(l);
            }
        }
        JSONArray jsonArray=new JSONArray(yjList);
        return jsonArray;
    }


    @Override
    public List<CustomerRegistration> findByLevel(String level){
        return customerRegistrationRepository.findByLevel(level);
    }

    public int findBySaleType(Integer id){
        return customerRegistrationRepository.findBySaleType(id);
    }

    @Override
    public Integer updatePublicPool(CustomerRegistration customerRegistration){
        return customerRegistrationRepository.update(customerRegistration);
    }


    @Override
    public List<CustomerRegistration> queryPublicCustomerList(String name){
        if (name != null){
            return customerRegistrationRepository.queryPublicCustomerListN(name);
        }else{
            return customerRegistrationRepository.queryPublicCustomerList();
        }
    }

    @Override
    public Integer artificialDistribution(CustomerRegistration customerRegistration){
        return customerRegistrationRepository.update(customerRegistration);
    }


    @Override
    public Integer randomAllocation(CustomReEntity customReEntity){
        CustomerRegistration customerRegistration = new CustomerRegistration();
        customerRegistration.setId(customReEntity.getCustomId());
        customerRegistration.setReceptionId(Integer.valueOf(customReEntity.getReceptionId()));
        customerRegistration.setReceptionName(customReEntity.getReceptionName());
        return customerRegistrationRepository.update(customerRegistration);
    }

    @Override
    public int updateComoCustom(CustomerRegistration customerRegistration) {
        return customerRegistrationRepository.update(customerRegistration);
    }

    @Override
    public List<String> queryCustomerList(CustomReEntity customReEntity) {
        List<Object> a = customerRegistrationRepository.queryCustomerList(customReEntity.getCustomId());
        ArrayList list = new ArrayList();
        Integer nMoneyBack = 0;
        Integer zj = 0;
        String moneyBack = "0";
        String totalActualAmount  = "0";   //最终成交价
        if (a.size() >  0){
            CustomerRegistration c = customerRegistrationRepository.queryCustomerRecordById(customReEntity.getCustomId());
            for (int j = 0;j < a.size();j ++){
                Object[] objects = (Object[]) a.get(j);
                String customerType = objects[0].toString(); //客户状态
                //根据状态查询回款
                if (customerType.equals("小订")){
                    moneyBack = c.getSmallSumMoney();
                }else if (customerType.equals("大定")){
                    moneyBack = c.getLargeSumMoney();
                }else if(customerType.equals("认筹")){
                    moneyBack = c.getIdentifyMoney();
                }else if (customerType.equals("已交首付")){
                    moneyBack = c.getDownPaymentsMoney();
                }else if (customerType.equals("已全款")){
                    moneyBack = objects[1].toString(); //已回款
                }
                //moneyBack = objects[1].toString(); //已回款
                String blockCode = objects[2].toString(); //栋号
                String unitCode = objects[3].toString(); //单元号
                String doorplateCode = objects[4].toString(); //门牌号
                String architectureArea = objects[5].toString(); //面积
                String discountTotal = objects[6].toString(); //优惠总价
                String oldTotal = objects[7].toString(); //原总价
                String houseId = objects[8].toString(); //房源id
                if (Integer.valueOf(discountTotal) > 0 && discountTotal.length() > 0){
                     nMoneyBack  = Integer.valueOf(discountTotal) - Integer.valueOf(moneyBack);
                     zj = Integer.valueOf(discountTotal);
                }else{
                    nMoneyBack  = Integer.valueOf(oldTotal) - Integer.valueOf(moneyBack);
                    zj = Integer.valueOf(oldTotal);
                }
                if (objects[9].toString().equals(0)){
                    totalActualAmount = "0";
                }else {
                    totalActualAmount = objects[9].toString(); //最终成交价
                }
                list.add(customerType);
                list.add(moneyBack);
                list.add(nMoneyBack);
                list.add(blockCode);
                list.add(unitCode);
                list.add(doorplateCode);
                list.add(architectureArea);
                list.add(zj);
                list.add(houseId);
                list.add(totalActualAmount);
            }
        }else{
             a = customerRegistrationRepository.queryCustomerListE(customReEntity.getCustomId());
            if (a.size() > 0){
                for (int j = 0;j < a.size();j ++){
                    Object[] objects = (Object[]) a.get(j);
                    String customerType = objects[0].toString(); //客户状态
                    moneyBack = objects[1].toString(); //已回款
                    String blockCode = "无"; //栋号
                    String unitCode = "无"; //单元号
                    String doorplateCode = "无"; //门牌号
                    String architectureArea = "无"; //面积
                    String discountTotal = "无"; //优惠总价
                    String oldTotal = "无"; //原总价
                    String houseId = "无"; //房源id
                    list.add(customerType);
                    list.add(moneyBack);
                    list.add(nMoneyBack);
                    list.add(blockCode);
                    list.add(unitCode);
                    list.add(doorplateCode);
                    list.add(architectureArea);
                    list.add(zj);
                    list.add(houseId);
                    list.add(totalActualAmount);
                }
            }
        }
        return list;
    }

    @Override
    public int modifyComoCustom(CustomReEntity customReEntity) {
        Integer code = -1;
        //修改房源价格表
        HouseDetail hd = new HouseDetail();
        if (customReEntity.getBlockCode() != null){
            hd.setBlockCode(Integer.valueOf(customReEntity.getBlockCode()));
        }
        if (customReEntity.getUnitCode() != null){
            hd.setUnitCode(customReEntity.getUnitCode());
        }
        if (customReEntity.getDoorplateCode() != null){
            hd.setDoorplateCode(customReEntity.getDoorplateCode());
        }
        if (customReEntity.getArchitectureArea() != null){
            hd.setArchitectureArea(customReEntity.getArchitectureArea());
        }
        if (customReEntity.getDiscountTotal() != null){
            hd.setDiscountTotal(Integer.valueOf(customReEntity.getDiscountTotal()));
        }
        hd.setId(Integer.valueOf(customReEntity.getHouseId()));
        if (houseDetailRepository.update(hd) > 0){
            code = 1;
        }
        //修改客户表
        CustomerRegistration cr = new CustomerRegistration();
        if (customReEntity.getCustomerType() != null){
            cr.setCustomerType(customReEntity.getCustomerType());
        }
        if (customReEntity.getMoneyBack() != null){
            cr.setMoneyBack(customReEntity.getMoneyBack());
        }
        cr.setId(Integer.valueOf(customReEntity.getCustomId()));
        if (customerRegistrationRepository.update(cr) > 0){
            code = 1;
        }
        return code;
    }

    @Override
    public int transferUser(String inputUser, String outUser) {
        User u = userServiceImpl.findByTelePhone(outUser);
        return customerRegistrationRepository.transferUser(inputUser,outUser,u.getName());
    }

    @Override
    public void saveInternetPublicUser(CustomerRegistration customerRegistration) {
        customerRegistrationRepository.save(customerRegistration);
    }

    public List<CustomerRegistration> queryCustomerDetail(String customerId){
        //201901204
        Integer i = 0;
        // 排序条件 默认最新
        Sort sort = new Sort(Sort.Direction.DESC, "id");
        //动态查询条件
        Specification<CustomerRegistration> specification = (Specification<CustomerRegistration>)(root,query, criteriaBuilder) -> {
            List<Predicate> list = new ArrayList<>();
            if (customerId != null) {
                Predicate p0 = criteriaBuilder.equal(root.get("id"), Integer.valueOf(customerId));
                list.add(p0);
            }
            return criteriaBuilder.and(list.toArray(new Predicate[0]));
        };
        List<CustomerRegistration> lst = customerRegistrationRepository.findAll(specification);
        //查询来访记录信息
        for(CustomerRegistration customerRegistration : lst){
            customerRegistration.setRecord(customerRegistrationRepository.queryCustomerRecordList(customerRegistration.getId()));
            customerRegistration.setLfNum(customerRegistration.getRecord().size());
        }
        return lst;
    }

    @Override
    public  List<Object> teamConversionRate(String sTime,String eTime){
        return  customerRegistrationRepository.teamConversionRate(sTime,eTime);
    }

    @Override
    public  List<String> fCustomer(){
        return  customerRegistrationRepository.fCustomer();
    }

    @Override
    public  int deleteFCustomer(String xnh){
        return  customerRegistrationRepository.deleteFCustomer(xnh);
    }

    public int updateCustomerType(CustomerRegistration customerRegistration){
        return customerRegistrationRepository.update(customerRegistration);
    }

    public int updateRc(Integer id){
        return customerRegistrationRepository.updateRc(id);
    }

    public int updateXd(Integer id){
        return customerRegistrationRepository.updateXd(id);
    }

    public int updateDd(Integer id){
        return customerRegistrationRepository.updateDd(id);
    }

    public int updateSf(Integer id){
        return customerRegistrationRepository.updateSf(id);
    }

    public int updateQk(Integer id){
        return customerRegistrationRepository.updateQk(id);
    }

    public int findFirst(String phone,String id) {
        Integer code = 0;
        CustomerRegistration c = customerRegistrationRepository.findFirst(phone);
        if (c.getId() != null) {
            if (id.equals(c.getReceptionId())) {
                code =  0;
            } else {
                code =  1;
            }
        }
        return code;
    }

    public String findBb(Integer id){
        return customerRegistrationRepository.findBb(id);
    }

    public String findvirtualNumber(Integer id){
        return customerRegistrationRepository.findvirtualNumber(id);
    }

    @Override
    public int findVirtualNumber(String virtualNumber){
        return customerRegistrationRepository.findVirtualNumber(virtualNumber);
    }

    @Override
    public int insertCustomerEType(CustomerRegistration customerRegistration){
        return customerRegistrationRepository.save(customerRegistration).getId();
    }
}
